Part Number Hot Search : 
DD1300 SP300 TEF6730 HMC128G8 PC3H715 TC9332 CAT508BP SMAJ3
Product Description
Full Text Search
 

To Download HT66F0176 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  a/d flash mcu with eeprom HT66F0176 revision: v1.20 date: ???? st 2?? 201? ????st 2?? 201?
rev. 1.20 2 ????st 2?? 201? rev. 1.20 3 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom table of contents eates cpu feat?res ......................................................................................................................... 6 peripheral feat?res ................................................................................................................. 6 general description ......................................................................................... ? block dia?ram .................................................................................................. ? pin ?ssi?nment ................................................................................................ ? pin description ................................................................................................ 9 ?bsol?te maxim?m ratin?s .......................................................................... 12 d.c. characteristics ....................................................................................... 12 operatin? v olta?e characteristics ........................................................................................ 12 standby c?rrent characteristics ........................................................................................... 13 operatin? c?rrent characteristics ......................................................................................... 14 ?.c. characteristics ....................................................................................... 15 hi?h speed internal oscillator C hirc C freq ?ency ?cc?racy ............................................. 15 low speed internal oscillator characteristics C l irc .......................................................... 15 o peratin? freq?ency characteristic c?rves ......................................................................... 16 s ystem start up time characteristics ................................................................................. 16 inp?t/o?tp?t characteristics ........................................................................ 1? memory characteristics ................................................................................ 1? ?/d converter electrical characteristics ..................................................... 1? reference volta?e characteristics ............................................................... 1? lvd/lvr electrical characteristics .............................................................. 1? software controlled lcd driver electrical characteristics ....................... 19 power-on reset characteristics ................................................................... 19 system ?rchitect?re ...................................................................................... 20 clockin? and pipelinin? ......................................................................................................... 20 pro?ram co?nter ................................................................................................................... 21 stack ..................................................................................................................................... 21 ?rithmetic and lo?ic unit C ?lu ........................................................................................... 22 flash pro?ram memory ................................................................................. 23 str?ct?re ................................................................................................................................ 23 special vectors ..................................................................................................................... 23 look-? p table ........................................................................................................................ 23 table pro ?ram example ........................................................................................................ 24 in circ?it pro?rammin? C icp ............................................................................................... 25 o n-chip deb?? s?pport C ocds ......................................................................................... 26 data memory .................................................................................................. 2? str?ct?re ................................................................................................................................ 2?
rev. 1.20 2 ????st 2?? 201? rev. 1.20 3 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom special function register description ........................................................ 29 indirect ?ddressin? re?isters C i?r0? i?r1 ......................................................................... 29 memory pointers C mp0? mp1 .............................................................................................. 29 b ank pointer C bp ................................................................................................................. 30 ?cc?m? lator C ?cc ............................................................................................................... 30 pro?ram co?nter low re?ister C pcl .................................................................................. 30 look-? p table re? isters C tblp ? tbhp ? tblh ..................................................................... 30 stat?s re?ister C st ? tus .................................................................................................... 31 eeprom data memory .................................................................................. 33 eeprom data memory str?ct?re ........................................................................................ 33 eeprom re?isters .............................................................................................................. 33 r eadin? data from the eeprom ......................................................................................... 35 w ritin? data to the eeprom ................................................................................................ 35 w rite protection ..................................................................................................................... 35 eeprom interr?pt ................................................................................................................ 35 p ro?rammin? considerations ................................................................................................ 36 oscillators ...................................................................................................... 37 oscillator overview ............................................................................................................... 3? system clock confgurations ................................................................................................ 3? e xternal crystal/ceramic oscillator C h xt ........................................................................... 3? i nternal hi?h speed rc oscillator C h irc ........................................................................... 39 e xternal 32.?6? khz crystal oscillator C lxt ....................................................................... 39 internal 32khz oscillator C lirc ........................................................................................... 40 s ?pplementary oscillators .................................................................................................... 40 operating modes and system clocks ......................................................... 41 system clocks ...................................................................................................................... 41 system operation modes ..................................................................................................... 42 control re?ister s .................................................................................................................. 43 f ast wake- ?p ........................................................................................................................ 45 op eratin? mode switchin? .................................................................................................... 46 standby c?rrent considerations ........................................................................................... 50 wake- ?p ................................................................................................................................ 50 p ro?rammin? considerations ................................................................................................ 51 watchdog timer ............................................................................................. 52 watchdo ? timer clock so?rce .............................................................................................. 52 watchdo ? timer control re?ister ......................................................................................... 52 watchdo ? timer operation ................................................................................................... 53 reset and initialisation .................................................................................. 54 reset f?nctions .................................................................................................................... 54 reset initial conditions ......................................................................................................... 56 input/output ports ......................................................................................... 59 p?ll-hi?h resistors ................................................................................................................ 59 port ? wake- ?p ..................................................................................................................... 60 i/o port control re?isters ..................................................................................................... 60
rev. 1.20 4 ????st 2?? 201? rev. 1.20 5 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom i/o port so?rce c?rrent control ............................................................................................ 61 pin -remappin? f?nction ........................................................................................................ 62 i/o pin str?ct?res .................................................................................................................. 63 pro?rammin? considerations ............................................................................................... 64 timer modules C tm ...................................................................................... 65 introd?ction ........................................................................................................................... 65 tm operation ........................................................................................................................ 65 tm clock so?rce ................................................................................................................... 65 tm interr?pts ......................................................................................................................... 66 tm external pins ................................................................................................................... 66 tm inp?t/o?tp?t pin control re?ister ................................................................................... 6? pro?rammin? considerations ................................................................................................ 6? periodic type tm C ptm ................................................................................ 69 p eriodic tm operation .......................................................................................................... 69 p eriodic type tm re ?ister description ................................................................................. ?0 p eriodic type tm operation modes ...................................................................................... ?4 analog to digital converter .......................................................................... 83 ?/d overview ........................................................................................................................ ?3 ?/d converter re?ister description ...................................................................................... ?4 ?/d converter inp?t si?nals .................................................................................................. ?? ?/d converter reference volta ?e ......................................................................................... ?? ?/d operation ....................................................................................................................... ?9 c onversion rate and timin ? dia?ram .................................................................................. 90 s?mmary of ?/d conversion steps ....................................................................................... 91 pro?rammin? considerations ................................................................................................ 92 ? /d transfer f?nction ........................................................................................................... 92 ?/d pro?rammin? examples ................................................................................................. 93 serial interface module C sim ....................................................................... 95 spi interface ......................................................................................................................... 95 i 2 c interface ........................................................................................................................ 101 scom/sseg function for lcd .................................................................... 111 lcd operation ..................................................................................................................... 111 lcd control re?isters ......................................................................................................... 112 uart interface .............................................................................................. 116 u? rt external pin ............................................................................................................... 11 ? u? rt data transfer scheme ............................................................................................... 11 ? u? rt stat?s and control re?isters ..................................................................................... 11 ? ba?d rate generator .......................................................................................................... 123 u? rt set?p and control ..................................................................................................... 124 u? rt transmitter ................................................................................................................ 125 u? rt receiver ................................................................................................................... 126 m ana?in? receiver errors .................................................................................................. 12? u? rt interr?pt str?ct?re ..................................................................................................... 129 u? rt power down and wake-?p ....................................................................................... 131
rev. 1.20 4 ????st 2?? 201? rev. 1.20 5 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom low voltage detector C lvd ....................................................................... 132 lvd re ?ister ....................................................................................................................... 132 lvd operation ..................................................................................................................... 133 interrupts ...................................................................................................... 134 interr?pt re?isters ............................................................................................................... 134 interr?pt operation .............................................................................................................. 13? external interr?pt ................................................................................................................. 140 m?lti-f?nction interr?pt ........................................................................................................ 140 ?/d converter interr?pt ....................................................................................................... 140 time base interr ?pt ............................................................................................................. 141 serial interface mod?le interr?pt ......................................................................................... 142 u? rt transfer interr?pt ...................................................................................................... 142 lvd interr ?pt ....................................................................................................................... 142 eeprom interr?pt .............................................................................................................. 142 tm interr?pt ......................................................................................................................... 143 interr? pt wake-?p f?nction ................................................................................................. 143 pro?rammin? considerations .............................................................................................. 144 confguration options ................................................................................. 145 application circuits ..................................................................................... 146 instruction set .............................................................................................. 147 introd?ction ......................................................................................................................... 14? instr? ction timin? ................................................................................................................ 14? movin? and transferrin? data ............................................................................................. 14? ?rithmetic operations .......................................................................................................... 14? lo?ical and rotate operation ............................................................................................. 14? branches and control transfer ........................................................................................... 14? bit operations ..................................................................................................................... 14? table read operations ....................................................................................................... 14? other operations ................................................................................................................. 14? instruction set summary ............................................................................ 149 table conventions ............................................................................................................... 149 instruction defnition ................................................................................... 151 package information ................................................................................... 160 16-pin nsop (150mil) o ?tline dimensions ......................................................................... 161 20-pin nsop (150mil) o ?tline dimensions ......................................................................... 162 24-pin sop (300mil) o ?tline dimensions ........................................................................... 163 24 -pin ssop ( 150 mil) o?tline dimensions ......................................................................... 164
rev. 1.20 6 ????st 2?? 201? rev. 1.20 ? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom features cpu features ? operating voltage f sys = 8mhz: 2.2v~5.5v f sys =12mhz: 2.7v~5.5v f sys =16mhz: 3.3v~5.5v ? up to 0.25 s instruction cycle with 16mhz system clock at v dd =5v ? power down and wake-up functions to reduce power consumption ? oscillator types: external high speed crystal C hxt external 32.768khz crystal C lxt internal high speed rc C hirc internal low speed 32khz rc C lirc ? multi-mode operation: fast, slow, idle and sleep ? fully integrated internal 8/12/16mhz oscillator requires no external components ? all instructions executed in one or two instruction cycles ? table read instructions ? 63 powerful instructions ? 8-level subroutine nesting ? bit manipulation instruction peripheral features ? flash program memory: 2k16 ? ram data memory: 128 8 ? true eeprom memory: 64 8 ? watchdog timer function ? 22 bidirectional i/o lines ? two pin-shared external interrupts ? dual timer modules for time measurement, compare match output or pwm output function ? serial interface module C sim for spi or i 2 c ? software controlled 6-scom/sseg and 14-sseg lines lcd driver with 1/3 bias ? programmable i/o port source current for led applications ? dual time-base functions for generation of fxed time interrupt signals ? 8-external channel 12-bit resolution a/d converter ? fully-duplex universal asynchronous receiver and transmitter interface C uart ? low voltage reset function ? low voltage detect function ? package types: 16/20-pin nsop, 24-pin sop/ssop
rev. 1.20 6 ????st 2?? 201? rev. 1.20 ? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom general description the HT66F0176 device is a flash memory a/d type 8-bit high performance risc architecture microcontroller. offering users the convenience of flash memory multi-programming features, the device also includes a wide range of functions and features. other memory includes an area of ram data memory as well as an area of true eeprom memory for storage of non-volatile data such as serial numbers, calibratuib data, etc. analog features include a multi-channel 12-bit a/d converter and a comparator functions. multiple and extremely flexible timer modules provide timing, pulse generation and pwm generation functions. communication with the outside world is catered for by including fully integrated spi, i 2 c, and uart interface functions, popular interfaces which provide designers with a means of easy communication with external peripheral hardware.protective features such as an internal watchdog timer, low voltage reset and low voltage detector coupled with excellent noise immunity and esd protection ensure that reliable operation is maintained in hostile electrical environments. a full choice of external, internal high and low oscillators are provided including a fully integrated system oscillator which requires no external components for its implementation. the ability to operate and switch dynamically between a range of operating modes using different clock sources gives users the ability to optimise microcontroller operation and minimize power consumption. the inclusion of fexible i/o programming features, time-base functions along with many other features ensure that the device will fnd excellent use in applications such as electronic metering, environmental monitoring, handheld instruments, household appliances, electronically controlled tools, motor driving in addition to many others. block diagram ?-bit risc mcu core i/o timer mod?les flash pro?ram memory eeprom data memory flash/eeprom pro?rammin? circ?itry (icp/ocds) r?m data memory time bases low volta?e reset watchdo? timer interr?pt controller reset circ?it lxt oscillator lcd driver sim (i 2 c/spi) 12-bit ?/d converter led driver u?rt low volta?e detect internal rc oscillators hxt oscillator
rev. 1.20 ? ????st 2?? 201? rev. 1.20 9 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom pin assignment 16 15 14 13 12 11 10 9 1 2 3 4 5 6 ? ? 20 19 1? 1? 16 15 14 13 12 11 1 2 3 4 5 6 ? ? 9 10 24 23 22 21 20 19 1? 1? 16 15 14 13 1 2 3 4 5 6 ? ? 9 10 11 12 p?2/[sdo]/icpck/ocdsck p?3/[sdi/sd?]/sseg3/scom3 pc0/sseg1?/osc1 pc1/sseg1?/osc2 p?0/tp0/icpd?/ocdsd? pb6/[sck/scl]/sseg4/scom4 vss/?vss pb1/int1/sseg15/?n1/xt2 p?5/[tck0]/sseg10/?n4/vref p?6/[tck1]/sseg9/?n5/vrefo p??/tp1/sseg?/?n6 pb3/[tx]/sseg?/?n? vdd/?vdd pb0/int0/sseg16/?n0/xt1 pb4/[rx]/clo/sseg6 p?2/[sdo]/icpck/ocdsck p?3/[sdi/sd?]/sseg3/scom3 pc0/sseg1?/osc1 pc1/sseg1?/osc2 pc2/sdo/sseg0/scom0 p?0/tp0/icpd?/ocdsd? pb6/[sck/scl]/sseg4/scom4 vss/?vss p?1/scs/sseg2/scom2 pb5/[scs]/sseg5/scom5 pb1/int1/sseg15/?n1/xt2 pb2/tck0/sseg14/?n2 p?4/tck1/sseg13/?n3 p?5/[tck0]/sseg10/?n4/vref p?6/[tck1]/sseg9/?n5/vrefo p??/tp1/sseg?/?n6 pb3/[tx]/sseg?/?n? vdd/?vdd pb0/int0/sseg16/?n0/xt1 pb4/[rx]/clo/sseg6 p?2/[sdo]/ic pck/ocdsck p?3/[sdi/sd?]/sseg3/scom3 pc0/sseg1?/osc1 pc1/sseg1?/osc2 pc2/sdo/sseg0/scom0 p?0/tp0/icpd?/ocdsd? pb6/[sck/scl]/sseg4/scom4 vss/?vss pc3/sdi/sd?/sseg19 pc4/sck/scl/ sseg1/scom1 p?1/scs/sseg2/scom2 pb5/[scs]/sseg5/scom5 pb1/int1/sseg15/?n1/xt2 pb2/tck0/sseg14/?n2 p?4/tck1/sseg13/?n3 p?5/[tck0]/sseg10/?n4/vref p?6/[tck1]/sseg9/?n5/vrefo p??/tp1/sseg?/?n6 pb3/[tx]/sseg?/?n? vdd/?vdd pb0/int0/sseg16/?n0/xt1 pb4/[rx]/clo/sseg6 pc5/[int1]/rx/sseg11 pc6/[int0]/tx/sseg12 HT66F0176/ht66v0176 16 nsop-a HT66F0176/ht66v0176 20 nsop-a HT66F0176/ht66v0176 24 sop/ssop-a p?1/scs/sseg2/scom2 note: 1. bracketed pin names indicate non-default pinout remapping locations. the detailed information can be referenced to the relevant chapter. 2. if the pin-shared functions have multiple outputs simultaneously, its pin names at the right side of the "/" sign can be used for higher priority. 3. the ocdsda and ocdsck pins are supplied for the ocds dedicated pins and as such only available for the ht66v0176 device which is the ocds ev chip for the HT66F0176 device.
rev. 1.20 ? ????st 2?? 201? rev. 1.20 9 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom pin description the function of each pin is listed in the following table, however the details behind how each pin is confgured is contained in other sections of the datasheet. pin name function opt i/t o/t description p ?0/tp0/icpd?/ ocdsd? p? 0 p ?pu p? wu st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p tp0 tmpc cmos ptm0 o?tp?t icpd? st cmos icp address/data ocdsd? st cmos ocds address/data? for ev chip only. p ?1/ scs /sseg2/ scom2 p? 1 p ?pu p? wu st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p scs ifs0 st cmos spi slave select sseg2 slcdc0 slcdc1 sseg lcd se?ment o?tp?t scom2 slcdc0 slcdc1 scom lcd common o?tp?t p ?2/sdo/icpck/ ocdsck p? 2 p ?pu p? wu st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p sdo ifs0 cmos spi data o?tp?t icpck st icp clock ocdsck st ocds clock pin? for ev chip only p ?3/sdi/sd?/ sseg3/scom3 p? 3 p ?pu p? wu st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p sdi ifs0 st spi serial data inp?t sd? ifs0 st nmos i 2 c data line sseg3 slcdc0 slcdc1 sseg lcd se?ment o?tp?t scom3 slcdc0 slcdc1 scom lcd common o?tp?t p ?4/tck1/sseg13/ ?n3 p? 4 p ?pu p? wu st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p tck1 ifs1 st ptm1 clock inp?t sseg13 slcdc2 sseg lcd se?ment o?tp?t ?n3 ?cerl ?n ?/d converter external inp?t p ?5/tck0/sseg10/ ?n4/vref p? 5 p ?pu p? wu st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p tck0 ifs1 st ptm0 clock inp?t sseg10 slcdc2 sseg lcd se?ment o?tp?t ?n4 ?cerl ?n ?/d converter external inp?t vr ef s?dc2 ?n ?/d converter reference volta?e inp?t p ?6/tck1/sseg9/ ?n5/vrefo p? 6 p ?pu p? wu st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p tck1 ifs1 st ptm1 clock inp?t sseg9 slcdc2 sseg lcd se?ment o?tp?t ?n5 ?cerl ?n ?/d converter external inp?t vrefo s?dc2 ?n ?/d converter reference volta?e o?tp?t p ??/tp1/sseg?/ ?n6 p ?? p ?pu p? wu st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p tp1 tmpc cmos ptm1 o?tp?t sseg? slcdc2 sseg lcd se?ment o?tp?t ?n6 ?cerl ?n ?/d converter external inp?t
rev. 1.20 10 ????st 2?? 201? rev. 1.20 11 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom pin name function opt i/t o/t description pb0/int0/sseg16/ ?n0/xt1 pb0 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p int0 ifs0 integ intc0 st external interr?pt 0 inp?t sseg16 slcdc3 sseg lcd se?ment o?tp?t ?n0 ?cerl ?n ?/d converter external inp?t xt1 co lxt lxt oscillator pin pb1/int1/sseg15/ ?n1/xt2 pb1 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p int1 ifs0 integ intc2 st external interr?pt 1 inp?t sseg15 slcdc3 sseg lcd se?ment o?tp?t ?n1 ?cerl ?n ?/d converter external inp?t xt2 co lxt lxt oscillator pin pb2/tck0/sseg14/ ?n2 pb2 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p tck0 ifs1 st ptm0 clock inp?t sseg14 slcdc3 sseg lcd se?ment o?tp?t ?n2 ?cerl ?n ?/d converter external inp?t pb3/tx/sseg?/?n? pb3 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p tx ifs1 cmos u? rt tx serial data o?tp?t sseg? slcdc2 sseg lcd se?ment o?tp?t ?n? ?cerl ?n ?/d converter external inp?t pb4/rx/clo/sseg6 pb4 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p rx ifs1 st u? rt rx serial data inp?t clo tmpc cmos system clock o?tp?t sseg6 slcdc2 sseg lcd se?ment o?tp?t pb5/ scs /sseg5/ scom5 pb5 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p scs ifs0 st cmos spi slave select sseg5 slcdc1 sseg lcd se?ment o?tp?t scom5 slcdc1 scom lcd common o?tp?t pb6/sck/scl/ sseg4/scom4 pb6 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p sck ifs0 st cmos spi serial clock scl ifs0 st nmos i 2 c clock line sseg4 slcdc1 sseg lcd se?ment o?tp?t scom4 slcdc1 scom lcd common o?tp?t pc0/sseg1?/osc1 pc0 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p sseg1? slcdc3 sseg lcd se?ment o?tp?t osc1 co hxt hxt oscillator pin pc1/sseg1?/osc2 pc1 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p sseg1? slcdc3 sseg lcd se?ment o?tp?t osc2 co hxt hxt oscillator pin pc2/sdo/sseg0/ scom0 pc2 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p sdo ifs0 cmos spi data o?tp?t sseg0 slcdc0 slcdc1 sseg lcd se?ment o?tp?t scom0 slcdc0 slcdc1 scom lcd common o?tp?t
rev. 1.20 10 ????st 2?? 201? rev. 1.20 11 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom pin name function opt i/t o/t description pc3/sdi/sd?/ sseg19 pc3 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p sdi ifs0 st spi serial data inp?t sd? ifs0 st nmos i 2 c data line sseg19 slcdc3 sseg lcd se?ment o?tp?t pc4/sck/scl/ sseg1/scom1 pc4 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p sck ifs0 st cmos spi serial clock scl ifs0 st nmos i 2 c clock line sseg1 slcdc0 slcdc1 sseg lcd se?ment o?tp?t scom1 slcdc0 slcdc1 scom lcd common o?tp?t pc5/int1/rx/ sseg11 pc5 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p int1 ifs0 integ intc2 st external interr?pt 1 inp?t rx ifs1 st u? rt rx serial data inp?t sseg11 slcdc2 sseg lcd se?ment o?tp?t pc6/int0/tx/ sseg12 pc6 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p int0 ifs0 integ intc0 st external interr?pt 0 inp?t tx ifs1 cmos u? rt tx serial data o?tp?t sseg12 slcdc2 sseg lcd se?ment o?tp?t vdd/? vdd vdd pwr di?ital positive power s?pply ? vdd pwr ?nalo? positive power s?pply vss/? vss vss pwr di?ital ne?ative power s?pply ??ro?nd ? vss pwr ?nalo? ne?ative power s?pply ??ro?nd legend: i/t: input type; o/t: output type; opt: optional by confguration option (co) or register option; co: confguration option; st: schmitt trigger input; an: analog signal; cmos: cmos output; nmos: nmos output; sseg: software controlled lcd seg; scom: software controlled lcd com; hxt: high frequency crystal oscillator; lxt: low frequency crystal oscillator pwr: power * the avdd pin is internally bonded together with the vdd pin while the avss pin is internally bonded together with the vss pin. as the pin description summary table applies to the package type with the most pins, not all of the above listed pins may be present on package types with smaller numbers of pins.
rev. 1.20 12 ????st 2?? 201? rev. 1.20 13 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom absolute maximum ratings supply voltage ................................................................................................ v ss ?0.3v to v ss +6.0v input voltage .................................................................................................. v ss ? 0.3v to v dd +0.3v storage temperature .................................................................................................... -50 ? c to 125?c operating temperature .................................................................................................. -40 ? c to 85 ? c i ol total ..................................................................................................................................... 80ma i oh total .................................................................................................................................... - 80ma total power dissipation ......................................................................................................... 500mw note: these are stress ratings only. stresses exceeding the range specified under "absolute maximum ratings" may cause substantial damage to the device. functional operation of the device at other conditions beyond those listed in the specifcation is not implied and prolonged exposure to extreme conditions may affect device reliability. d.c. characteristics for data in the following tables, note that factors such as oscillator type, operating voltage, operating frequency, pin load conditions, temperature and program instruction type, etc., can all exert an infuence on the measured values. operating v oltage characteristics ta= -40 c ~?5 c symbol parameter test conditions min. typ. max. unit v dd conditions v dd operatin? volta?e C hxt f sys =f hxt =?mhz 2.2 5.5 v f sys =f hxt =12mhz 2.? 5.5 f sys =f hxt =16mhz 3.3 5.5 operatin? volta?e C hirc f sys =f hirc =?mhz 2.2 5.5 v f sys =f hirc =12mhz 2.? 5.5 f sys =f hirc =16mhz 3.3 5.5 operatin? volta?e C lxt f sys =f lxt =32.?6?khz 2.2 5.5 v operatin? volta?e C lirc f sys =f lirc =32khz 2.2 5.5 v
rev. 1.20 12 ????st 2?? 201? rev. 1.20 13 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom standby current characteristics ta=25 c symbol standby mode test conditions min. typ. max. max. unit v dd conditions 85 c i stb sleep mode 2.2v wdt off 0.2 0.6 0.? a 3v 0.2 0.? 1.0 5v 0.5 1.0 1.2 2.2v wdt on 1.2 2.4 2.6 a 3v 1.5 3 3.2 5v 2.5 5 5.2 idle0 mode 2.2v f sub on 2.4 4 4.2 a 3v 3 5 6 5v 5 10 12 idle1 mode C hirc 2.2v f sub on? f sys =?mhz 0.25 0.5 0.? m? 3v 0.5 1.0 1.2 5v 1.0 2.0 2.2 2.?v f sub on? f sys =12mhz 1.0 2.0 2.2 m? 3v 1.2 2.4 2.4 5v 1.5 3.0 3.2 3.3v f sub on? f sys =16mhz 1.5 3.0 3.2 m? 5v 2.0 4.0 4.2 idle1 mode C hxt 2.2v f sub on? f sys =?mhz 0.25 0.5 0.? m? 3v 0.5 1.0 1.2 5v 1.0 2.0 2.2 2.?v f sub on? f sys =12mhz 1.0 2.0 2.2 m? 3v 1.2 2.4 2.4 5v 1.5 3.0 3.2 3.3v f sub on? f sys =16mhz 1.5 3.0 3.2 m? 5v 2.0 4.0 4.2 1rwhv :khqxvlqjwkhfkdudfwhulvwlfwdeohgdwdwkhiroorzlqjqrwhvvkrxogehwdnhqlqwrfrqvlghudwlrq qgljlwdolqsxwvduhvhwxslqdqrqrdwlqjfrqglwlrq oophdvxuhphqwvduhwdnhqxqghufrqglwlrqvriqrordgdqgzlwkdooshulskhudovlqdq riivwdwh ?khuhduhqr'&fxuuhqwsdwkv oo6wdqge&xuuhqwydoxhvduhwdnhqdiwhud +/? lqvwuxfwlrqh[hfxwlrqwkxvvwrsslqjdoolqvwuxfwlrq h[hfxwlrq
rev. 1.20 14 ????st 2?? 201? rev. 1.20 15 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom operating current characteristics ta=25 c symbol operating mode test conditions min. typ. max. unit v dd conditions i dd slow mode C lirc 2.2v f sys =32khz ? 16 a 3v 10 20 5v 30 50 slow mode C lxt 2.2v f sys =32?6?hz ? 16 a 3v 10 20 5v 30 50 fast mode C hirc 2.2v f sys =?mhz 0.? 1.0 m? 3v 2.0 2.? 5v 3.0 4.5 2.?v f sys =12mhz 1.0 1.5 m? 3v 3.0 4.2 5v 4.5 6.? 3.3v f sys =16mhz 3.0 4.5 m? 5v 6.0 9.0 fast mode C hxt 2.2v f sys =?mhz 0.? 1.2 m? 3v 1 1.5 5v 2.5 4.0 2.?v f sys =12mhz 1.2 2.2 m? 3v 1.5 2.5 5v 3.5 5.5 3.3v f sys =16mhz 3.2 4.? m? 5v 4.5 ?.0 1rwhv :khqxvlqjwkhfkdudfwhulvwlfwdeohgdwdwkhiroorzlqjqrwhvvkrxogehwdnhqlqwrfrqvlghudwlrq qgljlwdolqsxwvduhvhwxslqdqrqrdwlqjfrqglwlrq oophdvxuhphqwvduhwdnhqxqghufrqglwlrqvriqrordgdqgzlwkdooshulskhudovlqdq riivwdwh ?khuhduhqr'&fxuuhqwsdwkv oo2shudwlqj&xuuhqwydoxhvduhphdvxuhgxvlqjdfrqwlqxrxv123 lqvwuxfwlrqsurjudporrs
rev. 1.20 14 ????st 2?? 201? rev. 1.20 15 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom a.c. characteristics for data in the following tables, note that factors such as oscillator type, operating voltage, operating frequency and temperature etc., can all exert an infuence on the measured values. high speed internal oscillator C hirc C frequency accuracy during the program writing operation the writer will trim the hirc oscillator at a user selected hirc frequency and user selected voltage of either 3v or 5v . 8/12/16mhz symbol parameter test conditions min. typ. max. unit v dd temp. f hirc ? mhz writer trimmed hirc freq?ency 3v/5v ta=25c -1% ? +1% mhz ta= -40c ~ ?5c -2% ? +2% 2.2v~5.5v ta=25c -1.5% ? +1.5% ta= -40c ~ ?5c -3% ? +3% 12mhz writer trimmed hirc freq?ency 3v/5v ta=25c -1% 12 +1% mhz ta= -40c ~ ?5c -2% 12 +2% 2.?v~5.5v ta=25c -1.5% 12 +1.5% ta= -40c ~ ?5c -3% 12 +3% 16mhz writer trimmed hirc freq?ency 5v ta=25c -1% 16 +1% mhz ta= -40c ~ ?5c -2% 16 +2% 3.3v~5.5v ta=25c -1.5% 16 +1.5% ta= -40c ~ ?5c -3% 16 +3% notes: 1. the 3v/5v values for v dd are provided as these are the two selectable fxed voltages at which the hirc frequency is trimmed by the writer. 2. the row below the 3v/5v trim voltage row is provided to show the values for the full v dd range operating voltage. it is recommended that the trim voltage is fxed at 3v for application voltage ranges from 2.2v to 3.6v and fxed at 5v for application voltage ranges from 3.3v to 5.5v. 3. the minimum and maximum tolerance values provided in the table are only for the frequency at which the writer trims the hirc oscillator. after trimming at this chosen specifc frequency any change in hirc oscillator frequency using the oscillator register control bits by the application program will give a frequency tolerance to within 20%. low speed internal oscillator characteristics C l irc 7d &xohvvrwkhuzlvhvshflhg symbol parameter test conditions min. typ. max. unit v dd temp. f lirc oscillator freq?ency 5v ta=25c -10% 32 +10% khz 2.2v~5.5v ta= - 40c ~ ?5c -50% 32 +60%
rev. 1.20 16 ????st 2?? 201? rev. 1.20 1? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom o perating frequency characteristic curves system operating frequency operating voltage ?mhz 12mhz 16mhz 2.2v ~ ~ 2.?v 3.3v 5.5v ~ ~ ~ ~ operating voltage s ystem start up time characteristics ta= -40c~ ?5c symbol parameter test conditions min. typ. max. unit t sst system start- ? p time wake- ?p from condition where f sys is off f sys =f h ~ f h /64? f h =f hxt 12? t hxt f sys =f h ~ f h /64? f h =f hirc 16 t hirc f sys =f sub =f lxt 12? t lxt f sys =f sub =f lirc 2 t lirc system start- ? p time wake- ?p from condition where f sys is on. f sys =f h ~ f h /64? f h =f hxt or f hirc 2 t h f sys =f sub =f lxt or f lirc 2 t sub t rstd system reset delay time reset so ? rce from power-on reset or lvr hardware reset 25 50 100 ms system reset delay time lvrc/wdtc software reset system reset delay time reset source from wdt overfow ?.3 16.? 33.3 ms t sreset minim?m software reset width to reset 45 90 120 s otes 1. for the system start-up time values, whether f sys u ii s s p s d i sys p duddusuy6psud p p du yu i uus iu yddsuyiududps i sys i sys 6p 6s 6 p iiy p d iu dyd du du s
rev. 1.20 16 ????st 2?? 201? rev. 1.20 1? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom input/output characteristics ta=25c symbol parameter test conditions min. typ. max. unit v dd conditions v il inp? t low volta?e for i/o ports 5v 0 1.5 v 0 0.2v dd v ih inp?t hi? h volta?e for i/o ports 5v 3.5 5.0 v 0.?v dd v dd i ol sink c?rrent for i/o pins 3v v ol =0.1v dd 16 32 m? 5v 32 64 i oh so?rce c?rrent for i/o pins 3v v oh =0.9v dd ? pxps[n+1:n]=00? (x=?? b or c? n=0 or 2) -1.0 -2.0 m? 5v -2.0 -4.0 3v v oh =0.9v dd ? pxps[n+1:n]=01? (x=?? b or c? n=0 or 2) -1.?5 -3.5 5v -3.5 -?.0 3v v oh =0.9v dd ? pxps[n+1:n]=10? (x=?? b or c? n=0 or 2) -2.5 -5.0 5v -5.0 -10.0 3v v oh =0.9v dd ? pxps[n+1:n]=11? (x=?? b or c? n=0 or 2) -5.5 -11.0 5v -11.0 -22.0 r ph p?ll-hi?h resistance for i/o ports (note) 3v 20 60 100 k 5v 10 30 50 t tck tm clock inp?t minim?m p?lse width 0.3 s t int interr?pt inp?t pin minim?m p?lse width 10 s 1rwh ?kh 5 3+ lqwhuqdo sxoo kljk uhvlvwdqfh ydoxh lv fdofxodwhg e frqqhfwlqj wr jurxqg dqg hqdeolqj wkh lqsxw slq zlwk d sxookljk uhvlvwru dqg wkhq phdvxulqj wkh lqsxw vlqn fxuuhqw dw wkh vshflhg vxsso yrowdjh ohyho 'lylglqjwkhyrowdjhewklvphdvxuhgfxuuhqwsurylghvwkh5 3+ ydoxh memory characteristics ta= -40c~ ?5c symbol parameter test conditions min. typ. max. unit v dd conditions v rw v dd for read / write v ddmin v ddmax v program flash / data eeprom memory t dew erase / write cycle time 2 4 ms i ddpgm pro?rammin? / erase c?rrent on v dd 5.0 m? e p cell end?rance 100k e/w t retd rom data retention time ta=25c 40 year ram data memory v dr r?m data retention volta?e device in sleep mode 1.0 v
rev. 1.20 1? ????st 2?? 201? rev. 1.20 19 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom a/d converter electrical characteristics ta=25c symbol parameter test conditions min. typ. max. unit v dd conditions v dd operatin? volta?e 2.2 5.5 v v ?di inp? t volta?e 0 v ref v v ref reference volta ?e 2 v dd v dnl differential non-linearity 2.2v~2.?v v ref =v dd? t ?dck =8s 15 lsb 2.?v~5.5v v ref =v dd? t ?dck =0.5s or 10 s -3 +3 lsb inl inte?ral non-linearity 2.2v~2.?v v ref =v dd? t ?dck =8s 16 lsb 2.?v~5.5v v ref =v dd? t ?dck =0.5s or 10 s -4 +4 lsb i ?dc ?dditional c?rrent cons?mption for ?/d converter enable 3v no load? t ?dck =0.5 s 1.0 2.0 m? 5v no load? t ?dck =0.5 s 1.5 3.0 t ?dck clock period 2.2v~2.?v ? 10 s 2.?v~5.5v 0.5 10 s t ?dc conversion time (? /d sample and hold time) 12-bit ? /d converter 16 t ?dck t on2st ? /d converter on-to-start time 4 s reference voltage characteristics ta=25c symbol parameter test conditions min. typ. max. unit v dd conditions v bg band? ap reference volta?e -3% 1.04 +3% v t bgs v bg t ? rn on stable time no load 150 s lvd/lvr electrical characteristics ta=25c symbol parameter test conditions min. typ. max. unit v dd conditions v lvr low volta ? e reset volta?e lvr enable ? volta?e select 2.1v - 5% 2.1 + 5% v lvr enable ? volta?e select 2.55v 2.55 lvr enable ? volta?e select 3.15v 3.15 lvr enable ? volta?e select 3.?v 3.? v lvd low volta ? e detector volta?e lvd enable ? volta?e select 2.0v - 5% 2.0 + 5% v lvd enable ? volta?e select 2.2v 2.2 lvd enable ? volta?e select 2.4v 2.4 lvd enable ? volta?e select 2.?v 2.? lvd enable ? volta?e select 3.0v 3.0 lvd enable ? volta?e select 3.3v 3.3 lvd enable ? volta?e select 3.6v 3.6 lvd enable ? volta?e select 4.0v 4.0 t lvds lvdo stable time for lvr enable ? vbgen=0? lvd off on 15 s for lvr disable ? vbgen=0? lvd off on 150 t lvr minim? m low volta?e width to reset 120 240 4?0 s
rev. 1.20 1? ????st 2?? 201? rev. 1.20 19 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom symbol parameter test conditions min. typ. max. unit v dd conditions t lvd minim? m low volta?e width to interr?pt 60 120 240 s software controlled lcd driver electrical characteristics ta=25c symbol parameter test conditions min. typ. max. unit v dd conditions i bi?s bias c?rrent 5v isel[1:0]=00 4.2 ?.3 13 a isel[1:0]=01 ?.3 16.? 25 isel[1:0]=10 25 50 ?5 isel[1:0]=11 50 100 150 v lcd_h [(2/3) v dd ] volta?e for lcd scom/ sseg o?tp?t 2.2v~5.5v no load 0.645 0.6? 0.695 v dd v lcd_l [(1/3) v dd ] volta?e for lcd scom/ sseg o?tp?t 2.2v~5.5v no load 0.305 0.33 0.355 v dd power-on reset characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions v por v dd start volta ?e to ens?re power-on reset 100 mv rr por v dd risin? rate to ens?re power-on reset 0.035 v/ms t por minim? m time for v dd stays at v por to ens?re power-on reset 1 ms v dd t por rr por v por time
rev. 1.20 20 ????st 2?? 201? rev. 1.20 21 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom system architecture a key factor in the high-performance features of the holtek range of microcontrollers is attributed to their internal system architecture. the device takes advantage of the usual features found within risc microcontrollers providing increased speed of operation and enhanced performance. the pipelining scheme is implemented in such a way that instruction fetching and instruction execution are overlapped, hence instructions are effectively executed in one cycle, with the exception of branch or call instructions. an 8-bit wide alu is used in practically all instruction set operations, which carries out arithmetic operations, logic operations, rotation, increment, decrement, branch decisions, etc. the internal data path is simplified by moving data through the accumulator and the alu. certain internal registers are implemented in the data memory and can be directly or indirectly addressed. the simple addressing methods of these registers along with additional architectural features ensure that a minimum of external components is required to provide a functional i/o and a/d control system with maximum reliability and fexibility. this makes the device suitable for low- cost, high-volume production for controller applications. clocking and pipelining the main system clock, derived from either a hxt, lxt, hirc or lirc oscillator is subdivided into four internally generated non-overlapping clocks, t1~t4. the program counter is incremented at the beginning of the t1 clock during which time a new instruction is fetched. the remaining t2~t4 clocks carry out the decoding and execution functions. in this way, one t1~t4 clock cycle forms one instruction cycle. although the fetching and execution of instructions takes place in consecutive instruction cycles, the pipelining structure of the microcontroller ensures that instructions are effectively executed in one instruction cycle. the exception to this are instructions where the contents of the program counter are changed, such as subroutine calls or jumps, in which case the instruction will take one more instruction cycle to execute. fetch inst. (pc) (system clock) f sys phase clock t1 phase clock t2 phase clock t3 phase clock t4 pro?ram co?nter pc pc+1 pc+2 pipelinin? exec?te inst. (pc-1) fetch inst. (pc+1) exec?te inst. (pc) fetch inst. (pc+2) exec?te inst. (pc+1) system clocking and pipelining for instructions involving branches, such as jump or call instructions, two machine cycles are required to complete instruction execution. an extra cycle is required as the program takes one cycle to frst obtain the actual jump or call address and then another cycle to actually execute the branch. the requirement for this extra cycle should be taken into account by programmers in timing sensitive applications.
rev. 1.20 20 ????st 2?? 201? rev. 1.20 21 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom fetch inst. 1 1 mov ??[12h] 2 c?ll del?y 3 cpl [12h] 4 : 5 : 6 del?y: nop exec?te inst. 1 fetch inst. 2 exec?te inst. 2 fetch inst. 3 fl?sh pipeline fetch inst. 6 exec?te inst. 6 fetch inst. ? instruction fetching program counter during program execution, the program counter is used to keep track of the address of the next instruction to be executed. it is automatically incremented by one each time an instruction is executed except for instructions, such as "jmp" or "call" that demand a jump to a non- consecutive program memory address. only the lower 8 bits, known as the program counter low register, are directly addressable by the application program. when executing instructions requiring jumps to non-consecutive addresses such as a jump instruction, a subroutine call, interrupt or reset, etc., the microcontroller manages program control by loading the required address into the program counter. for conditional skip instructions, once the condition has been met, the next instruction, which has already been fetched during the present instruction execution, is discarded and a dummy cycle takes its place while the correct instruction is obtained. program counter high byte low byte (pcl) pc10~pc? pc?~pc0 program counter the lower byte of the program counter, known as the program counter low register or pcl, is available for program control and is a readable and writeable register. by transferring data directly into this register, a short program jump can be executed directly; however, as only this low byte is available for manipulation, the jumps are limited to the present page of memory that is 256 locations. when such program jumps are executed it should also be noted that a dummy cycle will be inserted. manipulating the pcl register may cause program branching, so an extra cycle is needed to pre-fetch. stack this is a special part of the memory which is use d to save the contents of the program counter only. the stack is organized into 8 levels and is neither part of the data nor part of the program space, and is neither readable nor writeable. the activated level is indexed by the stack pointer, and is neither readable nor writeable. at a subroutine call or interrupt acknowledge signal, the contents of the program counter are pushed onto the sta ck. at the end of a subroutine or an interrupt routine, signaled by a return instruction, ret or reti, the program counter is restored to its previous value from the stack. after a device reset, the stack pointer will point to the top of the stack. if the stack is full and an enabled interrupt takes place, the interrupt request fag will be recorded but the acknowledge signal will be inhibited. when the stack pointer is decremented, by ret or reti, the interrupt will be serviced. this feature prevents stack overfow allowing the programmer to use the structure more easily. however, when the stack is full, a call subroutine instruction can still be executed which will result in a stack overfow. precautions should be taken to avoid such cases which might cause unpredictable program branching. if the stack is overfow, the frst program counter save in the stack will be lost.
rev. 1.20 22 ????st 2?? 201? rev. 1.20 23 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom stack pointer stack level 2 stack level 1 stack level 3 : : : stack level ? pro?ram memory pro?ram co?nter bottom of stack top of stack arithmetic and logic unit C alu the arithmetic-logic unit or alu is a critical area of the microcontroller that carries out arithmetic and logic operations of the instruction set. connected to the main microcontroller data bus, the alu receives related instruction codes and performs the required arithmetic or logical operations after which the result will be placed in the specifed register. as these alu calculation or operations may result in carry, borrow or other status changes, the status register will be correspondingly updated to refect these changes. the alu supports the following functions: ? arithmetic operations: add, addm, adc, adcm, sub, subm, sbc, sbcm, daa ? logic operations: and, or, xor, andm, orm, xorm, cpl, cpla ? rotation: rra, rr, rrca, rrc, rla, rl, rlca, rlc ? increment and decrement: inca, inc, deca, dec ? branch decision: jmp, sz, sza, snz, siz, sdz, siza, sdza, call, ret, reti
rev. 1.20 22 ????st 2?? 201? rev. 1.20 23 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom flash program memory the program memory is the location where the user code or program is stored. for this device the program memory is flash type, which means it can be programmed and re-programmed a large number of times, allowing the user the convenience of code modifcation on the same device. by using the appropriate programming tools, the flash device offers users the fexibility to conveniently debug and develop their applications while also offering a means of field programming and updating. structure the program memory has a capacity of 2k16 bits. the program memory is addressed by the program counter and also contains data, table information and interrupt entries. table data, which can be setup in any location within the program me mory, is addressed by a separate table pointer registers. 000h initialisation vector 004h ?ffh 16 bits interr?pt vectors look-?p table n00h nffh 02ch program memory structure special vectors within the program memory, certain locations are reserved for the reset and interrupts. the location 000h is reserved for use by the device reset for program initialisation. after a device reset is initiated, the program will jump to this location and begin execution. look-up table any location within the program memory can be defned as a look-up table where programmers can store fxed data. to use the look-up table, the table pointer must frst be setup by placing the address of the look up data to be retrieved in the table pointer register, tblp and tbhp. these registers defne the total address of the look-up table. after setting up the table pointer, the table data can be retrieved from the program memory using the "tabrd [m]" or "tabrdl [m]" instructions respectively . when the instruction is executed, the lower order table byte from the program memory will be transferred to the user defned data memory register [m] as specified in the instruction. the higher order table data byte from the program memory will be transferred to the tblh special register.
rev. 1.20 24 ????st 2?? 201? rev. 1.20 25 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom the accompanying diagram illustrates the addressing data fow of the look-up table. last pa?e or tbhp re?ister tblp re?ister pro?ram memory re?ister tblh user selected re?ister ?ddress data 16 bits hi?h byte low byte table program example the accompanying example shows how the table pointer and table data is defned and retrieved from the device. this example uses raw table data located in the last page which is stored there using the org statement. the value at this org statement is "0700h" which refers to the start address of the last page within the 2k program memory of the device. the table pointer low byte register is setup here to have an initial value of "06h". this will ensure that the frst data read from the data table will be at the program memory address "0706h" or 6 locations after the start of the last page. note that the value for the table pointer is referenced to the frst address of the present page pointed by the tbhp register if the "tabrd [m]" instruction is being used. the high byte of the table data which in this case is equal to zero will be transferred to the tblh register automatically when the "tabrd [m]" instruction is executed. because the tblh register is a read-only register and cannot be restored, care should be taken to ensure its protection if both the main routine and interrupt service routine use table read instructions. if using the table read instructions, the interrupt service routines may change the value of the tblh and subsequently cause errors if used again by the main routine. as a rule it is recommended that simultaneous use of the table read instructions should be avoided. however, in situations where simultaneous use cannot be avoided, the interrupts should be disabled prior to the execution of any main routine table-read instructions. note that all table related instructions require two instruction cycles to complete their operation. table read program example tempreg1 db ? ; temporary register #1 tempreg2 db ? ; temporary register #2 : mov a,06h ; initialise low table pointer - note that this address is referenced mov tblp,a ; to the last page or the page that tbhp pointed mov a,07h ; initialise high table pointer mov tbhp,a : tabrd tempreg1 ; transfers value in table referenced by table pointer data at program ; memory address "0706h" transferred to tempreg1 and tblh dec tblp ; reduce value of table pointer by one tabrd tempreg2 ; transfers value in table referenced by table pointer data at program ; memory address "0705h" transferred to tempreg2 and tblh in this ; example the data "1ah" is transferred to tempreg1 and data "0fh" to ; register tempreg2 : org 0700h ; sets initial address of program memory dc 00ah, 00bh, 00ch, 00dh, 00eh, 00fh, 01ah, 01bh :
rev. 1.20 24 ????st 2?? 201? rev. 1.20 25 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom in circuit programming C icp the provision of flash type program memory provides the user with a means of convenient and easy upgrades and modifcations to their programs on the same device. as an additional convenience, holtek has provided a means of programming the microcontroller in- circuit using a 4-pin interface. this provides manufacturers with the possibility of manufacturing their circuit boards complete with a programmed or un-programmed microcontroller, and then programming or upgrading the program at a later stage. this enables product manufacturers to easily keep their manufactured products supplied with the latest program releases without removal and re- insertion of the device. holtek writer pins mcu programming pins pin description icpd? p? 0 pro?rammin? serial data/?ddress icpck p? 2 pro?rammin? clock vdd vdd power s?pply vss vss gro?nd the program memory and eeprom data memory can be programmed serially in-circuit using this 4-wire interface. data is downloaded and uploaded serially on a single pin with an additional line for the clock. two additional lines are required for the power supply. the technical details regarding the in-circuit programming of the device are beyond the scope of this document and will be supplied in supplementary literature. during the programming process, the user must take care of the icpda and icpck pins for data and clock programming purposes to ensure that no other outputs are connected to these two pins. * writer_vdd icpd? icpck writer_vss to other circ?it vdd p?0 p?2 vss writer connector si?nals mcu pro?rammin? pins * note: * may be resistor or capacitor. the resistance of * must be greater than 1k or the capacitance of * must be less than 1nf.
rev. 1.20 26 ????st 2?? 201? rev. 1.20 2? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom o n-chip debug support C ocds there is an ev chip named ht66v0176 which is used to emulate the real mcu device named HT66F0176. the ev chip device also provides the "on-chip debug" function to debug the real mcu device during development process. the ev chip and real mcu device, ht66v0176 and HT66F0176, are almost functional compatible except the "on-chip debug" function. users can use the ev chip device to emulate the real mcu device behaviors by connecting the ocdsda and ocdsck pins to the holtek ht-ide development tools. the ocdsda pin is the ocds data/address input/output pin while the ocdsck pin is the ocds clock input pin. when users use the ev chip device for debugging, the corresponding pin functions shared with the ocdsda and ocdsck pins in the real mcu device will have no effect in the ev chip. however, the two ocds pins which are pin-shared with the icp programming pins are still used as the flash memory programming pins for icp. for more detailed ocds information, refer to the corresponding document named "holtek e-link for 8-bit mcu ocds users guide". holtek e-link pins ev chip ocds pins pin description ocdsd? ocdsd? on-chip deb?? s?pport data/?ddress inp?t/o?tp?t ocdsck ocdsck on-chip deb?? s?pport clock inp?t vdd vdd power s?pply vss vss gro?nd
rev. 1.20 26 ????st 2?? 201? rev. 1.20 2? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom data memory the data memory is an 8-bit wide ram internal memory and is the location where temporary information is stored. structure divided into two parts, the frst of these is an area of ram, known as the special function data memory. here are located registers which are necessary for correct operation of the device. many of these registers can be read from and written to directly under program control, however, some remain protected from user manipulation. the second area of data memory is known as the general purpose data memory, which is reserved for general purpose use. all locations within this area are read and write accessible under program control. the overall data memory is subdivided into two banks. the special purpose data memory registers are accessible in all banks, with the exception of the eec register at address 40h, which is only accessible in bank 1. switching between the different data memory banks is achieved by setting the bank pointer to the correct value. the start address of the data memory for the device is the address 00h. the address range of the special purpose data m emory for the device is from 00h to 7fh while the address range of the general purpose data memory is from 80h to ffh. special purpose data memory general purpose data memory located banks capacity bank: address 0~1: 00h~?fh except eec re?ister (eec@40h in bank 1 only) 12? ? 0: ?0h~ffh data memory summary 00h ?fh ?0h ffh special p?rpose data memory general p?rpose data memory bank 0 bank 1 40h:eec (bank 1) data memory structure
rev. 1.20 2? ????st 2?? 201? rev. 1.20 29 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom 00h i?r0 01h mp0 02h i?r1 03h mp1 04h 05h ?cc 06h pcl 0?h tblp 0?h tblh 09h tbhp 0?h st?tus 0bh 0ch 0dh 0eh 0fh 10h intc0 11h 12h 19h p?pu 1?h p?wu 1bh 1?h 1dh 1ch 1fh p? p?c 13h 14h 15h 16h 1?h ee? 20h 21h 22h 2?h 23h 24h 25h 26h 2?h 40h 41h 42h 43h 44h 45h 46h 4?h 4?h 49h 4?h 4bh 4ch 4dh 4eh 4fh 50h 51h 53h 54h 1eh eec bank 0~1 55h 56h pbc pbpu pb ?fh bp lvdc lvrc eed s?dol s?dc0 pcc pcpu pc 5?h 5?h 59h 5?h s?doh 52h smod integ intc1 intc2 mfi0 mfi1 mfi2 tmpc wdtc tbc ctrl s?dc1 s?dc2 bank 0 bank 1 sledc0 usr ucr1 ucr2 txr_rxr brg sledc1 ?cerl simtoc simc0 simc1 simd sim?/simc2 slcdc0 slcdc1 slcdc2 slcdc3 ifs0 ifs1 29h 2?h 2bh 2ch 2dh 2eh 3?h 3?h 39h 3?h 3ch 3bh 3dh 3fh 3eh tm1c0 tm1c1 tm1dl tm1dh tm1?l tm1?h tm1rpl tm1rph 2fh 30h 31h 32h 33h 34h 35h tm0c0 tm0c1 tm0dl tm0dh tm0?l tm0?h tm0rpl : un?sed? read as 00h 36h tm0rph special purpose data memory structure
rev. 1.20 2? ????st 2?? 201? rev. 1.20 29 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom special function register description most of the special fun ction register details will be described in the relevant functional section. however, several registers require a separate description in this section. indirect addressing registers C iar0, iar1 the indirect addressing registers, iar0 and iar1, although having their locations in normal ram registers space, do not actually physically exist as normal registers. the method of indirect addressing for ram data manipulation uses these indirect addressing registers and memory pointers, in contrast to direct memory addressing, where the actual memory address is specifed. actions on the iar0 and iar1 registers will result in no actual read or write operation to these registers but rather to the memory location specified by their corresponding memory pointers, mp0 or mp1. acting as a pair, iar0 and mp0 can together access data only from bank 0 while the iar1 register together with mp1 register pair can access data from any data memory bank. as the indirect addressing registers are not physically implemented, reading the indirect addressing registers indirectly will return a result of "00h" and writing to the registers indirectly will result in no operation. memory pointers C mp0, mp1 two memory pointers, known as mp0 and mp1, are provided. these memory pointers are physically implemented in the data memory and can be manipulated in the same way as normal registers providing a convenient way with which to address and track data. when any operation to the relevant indirect addressing registers is carried out, the actual address that the microcontroller is directed to is the address specifed by the related memory pointer. mp0, together with indirect addressing register, iar0, are used to access data from bank 0, while mp1 together with iar1 are used to access data from all d ata banks according to the corresponding bp register. the following example shows how to clear a section of four data memory locations already defned as locations adres1 to adres4. indirect addressing program example data .section data adres1 db ? adres2 db ? adres3 db ? adres4 db ? block db ? code .section at 0 code org 00h start: mov a,04h ; setup size of block mov block,a mov a,offset adres1 ; accumulator loaded with frst ram address mov mp0,a ; setup memory pointer with frst ram address loop: clr iar0 ; clear the data at address defned by mp0 inc mp0 ; increment memory pointer sdz block ; check if last memory location has been cleared jmp loop continue: : the important point to note here is that in the example shown above, no reference is made to specifc ram addresses.
rev. 1.20 30 ????st 2?? 201? rev. 1.20 31 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom b ank pointer C bp for this device, the data memory is divided into two banks, bank0 and bank1. selecting the required data memory area is achieved using the bank pointer. bit 0 of the bank pointer is used to select data memory banks 0~1. the data memory is initialised to bank 0 after a reset, except for a wdt time-out reset in the power down mode, in which case, the data memory bank remains unaffected. directly addressing the data memory will always result in bank 0 being accessed irrespective of the value of the bank pointer. accessing data from bank1 must be implemented using indirect addressing. bp register bit 7 6 5 4 3 2 1 0 name dmbp0 r/w r/w por 0 bit 7~1 unimplemented, read as "0" bit 0 dmbp0 : select data memory banks 0: bank 0 1: bank 1 accumulator C acc the accumulator is central to the operation of any microcontroller and is closely related with operations carried out by the alu. the accumulator is the place where all intermediate results from the alu are stored. without the accumulator it would be necessary to write the result of each calculation or logical operation such as addition, subtraction, shift, etc., to the data memory resulting in higher programming and timing overheads. data transfer operations usually involve the temporary storage function of the accumulator; for example, when transferring data between one user defined register and another, it is necessary to do this by passing the data through the accumulator as no direct transfer between two registers is permitted. program counter low register C pcl to provide additional program control functions, the low byte of the program counter is made accessible to programmers by locating it within the special purpose area of the data memory. by manipulating this register, direct jumps to other program locations are easily implemented. loading a value directly into this pcl register will cause a jump to the specifed program memory location, however, as the register is only 8-bit wide, only jumps within the current program memory page are permitted. when such operations are used, note that a dummy cycle will be inserted. look-up table registers C tblp, tbhp, tblh these three special function registers are used to control operation of the look-up table which is stored in the program memory. tblp and tbhp are the table pointer and indicates the location where the table data is located. their value must be setup before any table read commands are executed. their value can be changed, for example using the "inc" or "dec" instructions, allowing for easy table data pointing and reading. tblh is the location where the high order byte of the table data is stored after a table read data instruction has been executed. note that the lower order table data byte is transferred to a user defned location.
rev. 1.20 30 ????st 2?? 201? rev. 1.20 31 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom status register C status this 8-bit register contains the zero fag (z), carry fag (c), auxiliary carry fag (ac), overfow fag (ov), power down fag (pdf), and watchdog time-out fag (to). these arithmetic/logical operation and system management fags are used to record the status and operation of the microcontroller. with the exception of the to and pdf fags, bits in the status register can be altered by instructions like most other registers. any data written into the status register will not change the to or pdf fag. in addition, operations related to the status register may give different results due to the different instruction operations. the to fag can be affected only by a system power-up, a wdt time-out or by executing the "clr wdt" or "halt" instruction. the pdf fag is affected only by executing the "halt" or "clr wdt" instruction or during a system power-up. the z, ov, ac, and c fags generally refect the status of the latest operations. ? c is set if an operation results in a carry during an addition operation or if a borrow does not take place during a subtraction operation; otherwise c is cleared. c is also affected by a rotate through carry instruction. ? ac is set if an operation results in a carry out of the low nibbles in addition, or no borrow from the high nibble into the low nibble in subtraction; otherwise ac is cleared. ? z is set if the result of an arithmetic or logical operation is zero; otherwise z is cleared. ? ov is set if an operation results in a carry into the highest-order bit but not a carry out of the highest-order bit, or vice versa; otherwise ov is cleared. ? pdf is cleared by a system power-up or executing the "clr wdt" instruction. pdf is set by executing the "halt" instruction. ? to is cleared by a system power-up or executing the "clr wdt" or "halt" instruction. to is set by a wdt time-out. in addition, on entering an interrupt sequence or executing a subroutine call, the status register will not be pushed onto the stack automatically. if the contents of the status registers are important and if the subroutine can corrupt the status register, precautions must be taken to correctly save it.
rev. 1.20 32 ????st 2?? 201? rev. 1.20 33 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom status register bit 7 6 5 4 3 2 1 0 name to pdf ov z ?c c r/w r r r/w r/w r/w r/w por 0 0 x x x x "x": ?nknown bit 7~6 unimplemented, read as "0" bit 5 to : watchdog time-out fag 0: after power up ow executing the "clr wdt" or "halt" instruction 1: a watchdog time-out occurred bit 4 pdf : power down fag 0: after power up ow executing the "clr wdt" instruction 1: by executing the "halt" instructin bit 3 ov : overfow fag 0: no overfow 1: an operation results in a carry into the highest-order bit but not a carry out of the highest-order bit or vice versa bit 2 z : zero fag 0: the result of an arithmetic or logical operation is not zero 1: the result of an arithmetic or logical operation is zero bit 1 ac : auxiliary fag 0: no auxiliary carry 1: an operation results in a carry out of the low nibbles, in addition, or no borrow from the high nibble into the low nibble in substraction bit 0 c : carry fag 0: no carry-out 1: an operation results in a carry during an addition operation or if a borrow does not take place during a subtraction operation the "c" fag is also affected by a rotate through carry instruction.
rev. 1.20 32 ????st 2?? 201? rev. 1.20 33 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom eeprom data memory the device contains an area of internal eeprom data memory. eeprom, which stands for electrically erasable programmable read only memory, is by its nature a non-volatile form of re-programmable memory, with data retention even when its power supply is removed. by incorporating this kind of data memory, a whole new host of application possibilities are made available to the designer. the availability of eeprom storage allows information such as product identification numbers, calibration values, specific user data, system setup data or other product information to be stored directly within the product microcontroller. the process of reading and writing data to the eeprom memory has been reduced to a very trivial affair. eeprom data memory structure the eeprom data memory capacity is 648 bits for the device. unlike the program memory and ram data memory, the eeprom data memory is not directly mapped into memory space and is therefore not directly addressable in the same way as the other types of memory. read and write operations to the eeprom are carried out in single byte operations using an address and data register in bank 0 and a single control register in bank 1. eeprom registers three registers control the overall operation of the internal eeprom data memory. these are the address registers, eea, the data register, eed and a single control register, eec. as the eea and eed registers are located in bank 0, they can be directly accessed in the same was as any other special function register. the eec register, however, being located in bank 1, can be read from or written to indirectly using the mp1 memory pointer and indirect addressing register, iar1. because the eec control register is located at address 40h in bank 1, the mp1 memory pointer register must frst be set to the value 40h and the bank pointer register, bp, set to the value, 01h, before any operations on the eec register are executed. register name bit 7 6 5 4 3 2 1 0 ee? ee?5 ee?4 ee?3 ee?2 ee?1 ee?0 eed d? d6 d5 d4 d3 d2 d1 d0 eec wren wr rden rd eeprom registers list eea register bit 7 6 5 4 3 2 1 0 name ee?5 ee?4 ee?3 ee?2 ee?1 ee?0 r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 bit 7~6 unimplemented, read as "0" bit 5~0 eea5~eea0 : data eeprom address low byte register data eeprom address bit 5 ~ bit 0
rev. 1.20 34 ????st 2?? 201? rev. 1.20 35 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom eed register bit 7 6 5 4 3 2 1 0 name d? d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~0 d7~d0 : data eeprom data bit 7 ~ bit 0 eec register bit 7 6 5 4 3 2 1 0 name wren wr rden rd r/w r/w r/w r/w r/w por 0 0 0 0 bit 7~4 unimplemented, read as "0" bit 3 wren : data eeprom write enable 0: disable 1: enable this is the data eeprom write enable bit which must be set high before data eeprom write operations are carried out. clearing this bit to zero will inhibit data eeprom write operations. bit 2 wr : data eeprom write control 0: write cycle has fnished 1: activate a write cycle this is the data eeprom write control bit and when set high by the application program will activate a write cycle. this bit will be automatically reset to zero by the hardware after the write cycle has fnished. setting this bit high will have no effect if the wren has not frst been set high. bit 1 rden : data eeprom read enable 0: disable 1: enable this is the data eeprom read enable bit which must be set high before data eeprom read operations are carried out. clearing this bit to zero will inhibit data eeprom read operations. bit 0 rd : data eeprom read control 0: read cycle has fnished 1: activate a read cycle this is the data eeprom read control bit and when set high by the application program will activate a read cycle. this bit will be automatically reset to zero by the hardware after the read cycle has fnished. setting this bit high will have no effect if the rden has not frst been set high. note: the wren, wr, rden and rd can not be set to "1" at the same time in one instruction. the wr and rd can not be set to "1" at the same time.
rev. 1.20 34 ????st 2?? 201? rev. 1.20 35 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom r eading data from the eeprom to read data from the eeprom, the read enable bit, rden, in the eec register must frst be set high to enable the read function. the eeprom address of the data to be read must then be placed in the eea register. if the rd bit in the eec register is now set high, a read cycle will be initiated. setting the rd bit high will not initiate a read operation if the rden bit has not been set. when the read cycle terminates, the rd bit will be automatically cleared to zero, after which the data can be read from the eed register. the data will remain in the eed register until another read or write operation is executed. the application program can poll the rd bit to determine when the data is valid for reading. w riting data to the eeprom the eeprom address of the data to be written must frst be placed in the eea register and the data placed in the eed register. to write data to the eeprom, the write enable bit, wren, in the eec register must frst be set high to enable the write function. after this, the wr bit in the eec register must be immediately set high to initiate a write cycle. these two instructions must be executed consecutively. the global interrupt bit emi should also frst be cleared before implementing any write operations, and then set again after the write cycle has started. note that setting the wr bit high will not initiate a write cycle if the wren bit has not been set. as the eeprom write cycle is controlled using an internal timer whose operation is asynchronous to microcontroller system clock, a certain time will elapse before the data will have been written into the eeprom. detecting when the write cycle has fnished can be implemented either by polling the wr bit in the eec register or by using the eeprom interrupt. when the write cycle terminates, the wr bit will be automatically cleared to zero by the microcontroller, informing the user that the data has been written to the eeprom. the application program can therefore poll the wr bit to determine when the write cycle has ended. w rite protection protection against inadvertent write operation is provided in several ways. after the device is powered on, the write enable bit in the control register will be cleared preventing any write operations. also at power-on the bank pointer register, bp, will be reset to zero, which means that data memory bank 0 will be selected. as the eeprom control register is located in bank 1, this adds a further measure of protection against spurious write operations. during normal program operation, ensuring that the write enable bit in the control register is cleared will safeguard against incorrect write operations. eeprom interrupt the eeprom write interrupt is generated when an eeprom write cycle has ended. the eeprom interrupt must frst be enabled by setting the dee bit in the relevant interrupt register. however, as the eeprom is contained within a multi-function interrupt, the associated multi-function interrupt enable bit must also be set. when an eeprom write cycle ends, the def request flag and its associated multi-function interrupt request fag will both be set. if the global, eeprom and multi- function interrupts are enabled and the stack is not full, a jump to the associated multi-function interrupt vector will take place. when the interrupt is serviced only the multi-function interrupt fag will be automatically reset, the eeprom interrupt fag must be manually reset by the application program.
rev. 1.20 36 ????st 2?? 201? rev. 1.20 3? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom p rogramming considerations care must be taken that data is not inadvertently written to the eeprom. protection can be periodic by ensuring that the write enable bit is normally cleared to zero when not writing. also the bank pointer register could be normally cleared to zero as this would inhibit access to bank1 where the eeprom control register exist. although certainly not necessary, consideration might be given in the application program to the checking of the validity of new write data by a simple read back process. when writing data the wr bit must be set high immediately after the wren bit has been set high, to ensure the write cycle executes correctly. the global interrupt bit emi should also be cleared before a write cycle is executed and then re-enabled after the write cycle starts. note that the device should not enter the idle or sleep mode until the eeprom read or write operation is totally complete. otherwise, the eeprom read or write operation will fail. programming examples ? reading data from the eeprom C polling method 029 ((3520b5(6 xvhughhgdgguhvv 029 (( 029 vhwxsphprusrlwhu03 029 03 03srlwvwr((&uhjlvwhu 029 vhwxsdn3rlwhu3 029 3 6(7 ,5 vhw5(1elwhdeohuhdgrshudwlrv 6(7 ,5 vwduw5hdg&fohvhw5elw back: 6 ,5 fkhfhdffhh -03 . /5 ,5 ldeh3520lh /5 3 02 hhdddhlh 02 5b7 ? writing data to the eeprom C polling method 029 ((3520b5(6 xvhughhgdgguhvv 029 (( 029 ((3520b7 xvhughhggdwd 029 (( 029 vhwxsphprusrlwhu03 029 03 03srlwvwr((&uhjlvwhu 029 vhwxsdn3rlwhu3 029 3 &/5 (0, 6(7 ,5 vhw:5(1elwhdeohzulwhrshudwlrv 6(7 ,5 vwduw:ulwh&fohvhw:5elwh[hfxwhglpphgldwho 6(7 (0, back: 6 ,5 fkhflhffhh -03 . /5 ,5 ldeh3520lh /5 3
rev. 1.20 36 ????st 2?? 201? rev. 1.20 3? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom oscillators various oscillator types offer the user a wide range of functions according to their various application requirements. the fexible features of the oscillator functions ensure that the best optimisation can be achieved in terms of speed and power saving. oscillator selections and operation are selected through a combination of confguration options and relevant control registers. oscillator overview in addition to being the source of the main system clock the oscillators also provide clock sources for the watchdog timer and time base interrupts. external oscillators requiring some external components as well as fully integrated internal oscillators, requiring no external components, are provided to form a wide range of both fast and slow system oscillators. all oscillator options are selected through confguration options. the higher frequency oscillators provide higher performance but carry with it the disadvantage of higher power requirements, while the opposite is of course true for the lower frequency oscillators. with the capability of dynamically switching between fast and slow system clock, the device has the fexibility to optimize the performance/power ratio, a feature especially important in power sensitive portable applications. type name frequency pins hi?h speed external crystal hxt 400 khz~20 mhz osc1/osc2 hi?h speed internal rc hirc ?/12/16 mhz low speed external crystal lxt 32.?6? khz xt1/xt2 low speed internal rc lirc 32 khz oscillator types system clock confgurations there are four methods of generating the system clock, two high speed oscillators and two low speed oscillators for the device. the high speed oscillator is the external crystal/ceramic oscillator, hxt, and the internal 8/12/16 mhz rc oscillator, hirc. the two low speed oscillators are the internal 32 khz rc oscillator, lirc, and the external 32.768 khz crystal oscillator, lxt. selecting whether the low or high speed oscillator is used as the system oscillator is implemented using the hlclk bit and cks2~cks0 bits in the smod register and as the system clock can be dynamically selected. the actual source clock used for each of the high and low speed oscillators is chosen via configuration options. the frequency of the slow speed or high speed system clock is also determined using the hlclk bit and cks2~cks0 bits in the smod register. note that two oscillator selections must be made namely one high speed and one low speed system oscillators. it is not possible to choose a no-oscillator selection for either the high or low speed oscillator. the osc1 and osc2 pins are used to connect the external components for the external crystal.
rev. 1.20 3? ????st 2?? 201? rev. 1.20 39 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom hirc prescaler f h lxt hi?h speed oscillators low speed oscillators f h /2 f h /16 f h /64 f h /? f h /4 f h /32 hlclk? cks2~cks0 f sys f sub f sub lirc hxt f h hi?h speed oscillator confi??ration option low speed oscillator confi??ration option fast wake-?p from idle or sleep mode control (for hxt only ) system clock confgurations e xternal crystal/ceramic oscillator C h xt the external crystal/ceramic system oscillator is one of the high frequency oscillator choices, which is selected via configuration option. for most crystal oscillator configurations, the simple connection of a crystal across osc1 and osc2 will create the necessary phase shift and feedback for oscillation, without requiring external capacitors. however, for some crystal types and frequencies, to ensure oscillation, it may be necessary to add two small value capacitors, c1 and c2. using a ceramic resonator will usually require two small value capacitors, c1 and c2, to be connected as shown for oscillation to occur. the values of c1 and c2 should be selected in consultation with the crystal or resonator manufacturers specifcation. for oscillator stability and to minimise the effects of noise and crosstalk, it is important to ensure that the crystal and any associated resistors and capacitors along with interconnecting lines are all located as close to the mcu as possible. note: 1. r p is normally not req?ired. c1 and c2 are req?ired. 2. ?ltho??h not shown osc1/o sc2 pins have a parasitic capacitance of aro?nd ?pf. to internal circ?its internal oscillator circuit c1 c2 osc1 osc2 r f r p crystal/resonator oscillator hxt oscillator c1 and c2 values crystal frequency c1 c2 16mhz 0 pf 0 pf 12mhz 0 pf 0 pf ?mhz 0 pf 0 pf 4mhz 0 pf 0 pf 1mhz 100 pf 100 pf note : c1 and c2 val?es are for ?? idance only. crystal recommended capacitor values
rev. 1.20 3? ????st 2?? 201? rev. 1.20 39 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom i nternal high speed rc oscillator C h irc the internal rc oscillator is a fully integrated system oscillator requiring no external components. the internal rc oscillator has three fixed frequencies of 8mhz, 12mhz and 16mhz. device trimming during the manufacturing process and the inclusion of internal frequency compensation circuits are used to ensure that the infuence of the power supply voltage, temperature and process variations on the oscillation frequency are minimised. as a result, at a power supply of either 3v or 5v and at a temperature of 25c degrees, the fxed oscillation frequency of 8mhz, 12mhz or 16mhz will have a tolerance within 1%. note that if this internal system clock option is selected, as it requires no external pins for its operation, i/o pins are free for use as normal i/o pins. e xternal 32.768 khz crystal oscillator C lxt the external 32.768khz crystal system oscillator is one of the low frequency oscillator choices, which is selected via confguration option. this clock source has a fxed frequency of 32.768 khz and requires a 32.768 khz crystal to be connected between pins xt1 and xt2. the external resistor and capacitor components connected to the 32.768 khz crystal are necessary to provide oscillation. for applications where precise frequencies are essential, these components may be required to provide frequency compensation due to different crystal manufacturing tolerances. during power-up there is a time delay associated with the lxt oscillator waiting for it to start-up. when the microcontroller enters the sleep or idle mode, the system clock is switched off to stop microcontroller activity and to conserve power. however, in many microcontroller applications it may be necessary to keep the internal timers operational even when the microcontroller is in the sleep or idle mode. to do this, another clock, independent of the system clock, must be provided. however, for some crystals, to ensure oscillation and accurate frequency generation, it is necessary to add two small value external capacitors, c1 and c2. the exact values of c1 and c2 should be selected in consultation with the crystal or resonator manufacturer specification. the external parallel feedback resistor, r p , is required. some confguration options determine if the xt1/xt2 pins are used for the lxt oscillator or as i/o or other pin-shared functional pins. ? if the lxt oscillator is not used for any clock source, the xt1/xt2 pins can be used as normal i/o or other pin-shared functional pins. ? if the lxt oscillator is used for any clock source, the 32.768 khz crystal should be connected to the xt1/xt2 pins. for oscillator stability and to minimise the effects of noise and crosstalk, it is important to ensure that the crystal and any associated resistors and capacitors along with interconnecting lines are all located as close to the mcu as possible. note: 1. r p ? c1 and c2 are req?ired. 2. ?ltho??h not shown xt1/xt 2 pins have a parasitic capacitance of aro?nd ?pf. to internal circ?its internal oscillator circuit c1 c2 xt1 xt2 r p 32.?6? khz internal rc oscillator external lxt oscillator
rev. 1.20 40 ????st 2?? 201? rev. 1.20 41 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom lxt oscillator c1 and c2 values crystal frequency c1 c2 32.?6? khz 10 pf 10 pf note : 1. c1 and c2 val?es are for ?? idance only. 2. r p =5m~10m is recommended. 32.768 khz crystal recommended capacitor values lxt oscillator low power function the lxt oscillator can function in one of two modes, the quick start mode and the low power mode. the mode selection is executed using the lxtlp bit in the tbc register. lxtlp bit lxt mode 0 q?ick start 1 low-power after power on, the lxtlp bit will be automatically cleared to zero ensuring that the lxt oscillator is in the quick start operating mode. in the quick start mode the lxt oscillator will power up and stabilise quickly. however, after the lxt oscillator has fully powered up it can be placed into the low-power mode by setting the lxtlp bit high. the oscillator will continue to run but with reduced current consumption, as the higher current consumption is only required during the lxt oscillator start-up. in power sensitive applications, such as battery applications, where power consumption must be kept to a minimum, it is therefore recommended that the application program sets the lxtlp bit high about 2 seconds after power-on. it should be noted that, no matter what condition the lxtlp bit is set to, the lxt oscillator will always function normally, the only difference is that it will take more time to start up if in the low-power mode. internal 32khz oscillator C lirc the internal 32khz system oscillator is one of the low frequency oscillator choices, which is selected via confguration option. it is a fully integrated rc oscillator with a typical frequency of 32khz from 2.2v to 5.5v, requiring no external components for its implementation. device trimming during the manufacturing process and the inclusion of internal frequency compensation circuits are used to ensure that the infuence of the power supply voltage, temperature and process variations on the oscillation frequency are minimised. s upplementary oscillators the low speed oscillators, in addition to providing a system clock source are also used to provide a clock source to two other device functions. these are the watchdog timer and the time base interrupts.
rev. 1.20 40 ????st 2?? 201? rev. 1.20 41 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom operating modes and system clocks present day applications require that their microcontrollers have high performance but often still demand that they consume as little power as possible, conficting requirements that are especially true in battery powered portable applications. the fast clocks required for high performance will by their nature increase current consumption and of course, vice-versa, lower speed clocks reduce current consumption. as holtek has provided the device with both high and low speed clock sources and the means to switch between them dynamically, the user can optimise the operation of their microcontroller to achieve the best performance/power ratio. system clocks the device has many different clock sources for both the cpu and peripheral function operation. by providing the user with a wide range of clock options using confguration options and register programming, a clock system can be confgured to obtain maximum application performance. the main system clock, can come from either a high frequency f h or low frequency f sub source, and is selected using the hlclk bit and cks2~cks0 bits in the smod register. the high speed system clock can be sourced from either an hxt or hirc oscillator, selected via a confguration option. the low speed system clock source can be sourced from internal clock f sub . if f sub is selected then it can be sourced by either the lxt or lirc oscillator, selected via a confguration option. the other choice, which is a divided version of the high speed system oscillator has a range of f h /2~ f h /64. there are two additional internal clocks for the peripheral circuits, the substitute clock, f sub , and the time base clock, f tbc . each of these internal clocks is sourced by either the lxt or lirc oscillators, selected via confguration options. the f sub clock is used to provide a substitute clock for the microcontroller just after a wake-up has occurred to enable faster wake-up times. hirc prescaler f h lxt hi?h speed oscillators low speed oscillators f h /2 f h /16 f h /64 f h /? f h /4 f h /32 hlclk? cks2~cks0 f sys f sub f sub lirc hxt f h hi?h speed oscillator confi??ration option low speed oscillator confi??ration option fast wake-?p from idle or sleep mode control (for hxt only ) f sub idlen f tbc f sys /4 tbck f tb time base wdt f sub f tbc device clock confgurations note: when the system clock source f sys is switched to f sub from f h , the high speed oscillator will stop to conserve the power. thus there is no f h ~f h /64 for peripheral circuit to use.
rev. 1.20 42 ????st 2?? 201? rev. 1.20 43 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom system operation modes there are six different operation modes for the microcontroller, each one with its own special characteristics and which can be chosen according to the specific performance and power requirements of the application. there are two modes allowing normal operation of the microcontroller, the fast mode and slow mode. the remaining four modes, the sleep0, sleep1, idle0 and idle1 mode, are used when the microcontroller cpu is switched off to conserve power. operation mode description cpu f sys f sub f tbc f ?st on f h ~f h /64 on on slow on f sub on on idle0 off off on on idle1 off on on on sleep0 off off off off sleep1 off off on off fast mode as the name suggests this is one of the main operating modes where the microcontroller has all of its functions operational and where the system clock is provided by one of the high speed oscillators. this mode operates allowing the microcontroller to operate normally with a clock source will come from one of the high speed oscillators, either the hxt or hirc oscillators. the high speed oscillator will however frst be divided by a ratio ranging from 1 to 64, the actual ratio being selected by the cks2~cks0 and hlclk bits in the smod register. although a high speed oscillator is used, running the microcontroller at a divided clock ratio reduces the operating current. slow mode this is also a mode where the microcontroller operates normally although now with a slower speed clock source. the clock source used will be from one of the low speed oscillators, either the lxt or the lirc. running the microcontroller in this mode allows it to run with much lower operating currents. in the slow mode, the f h is off. sleep0 mode the sleep0 mode is entered when an halt instruction is executed and when the idlen bit in the smod register is low. in the sleep0 mode the cpu will be stopped, the f sub clock will also be stopped and the watchdog timer function is disabled. in this mode, the lvden must be set to "0". if the lvden is set to "1", it wont enter the sleep0 mode. sleep1 mode the sleep1 mode is entered when an halt instruction is executed and when the idlen bit in the smod register is low. in the sleep1 mode the cpu will be stopped. however the f sub clock will continue to operate if the lvden is "1" or the watchdog timer function is enabled. idle0 mode the idle0 mode is entered when a halt instruction is executed and when the idlen bit in the smod register is high and the fsyson bit in the ctrl register is low. in the idle0 mode the system oscillator will be inhibited from driving the cpu but some peripheral functions will remain operational such as the watchdog timer and tms. in the idle0 mode, the system oscillator will be stopped.
rev. 1.20 42 ????st 2?? 201? rev. 1.20 43 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom idle1 mode the idle1 mode is entered when an halt instruction is executed and when the idlen bit in the smod register is high and the fsyson bit in the ctrl register is high. in the idle1 mode the system oscillator will be inhibited from driving the cpu but may continue to provide a clock source to keep some peripheral functions operational such as the watchdog timer and tms. in the idle1 mode, the system oscillator will continue to run, and this system oscillator may be high speed or low speed system oscillator. control register s a single register, smod, is used for overall control of the internal clocks within the device. smod register bit 7 6 5 4 3 2 1 0 name cks2 cks1 cks0 fsten lto hto idlen hlclk r/w r/w r/w r/w r/w r r r/w r/w por 0 0 0 0 0 0 1 1 bit 7~5 cks2~cks0 : system clock selection when hlclk is "0" 000: f 001: f 010: f h /64 011: f h /32 100: f h /16 101: f h /8 110: f h /4 111: f h /2 these three bits are used to select which clock is used as the system clock source. in addition to the system clock source, which can be either the lxt or lirc, a divided version of the high speed system oscillator can also be chosen as the system clock source. bit 4 fsten : fast wake-up control (only for hxt) 0: disable 1: enable this is the fast wake-up control bit which determines if the f clock source is initially used after the device wakes up. when the bit is high, the f clock source can be used as a temporary system clock to provide a faster wake up time as the f clock is available. bit 3 lto : low speed system oscillator ready fag 0: not ready 1: ready this is the low speed system oscillator ready fag which indicates when the low speed system oscillator is stable after power on reset or a wake-up has occurred. the fag will be low when in the sleep0 mode but after a wake-up has occurred, the fag will change to a high level after 128 clock cycles if the lxt oscillator is used and 1~2 clock cycles if the lirc oscillator is used. bit 2 hto : high speed system oscillator ready fag 0: not ready 1: ready this is the high speed system oscillator ready fag which indicates when the high speed system oscillator is stable. this fag is cleared to "0" by hardware when the device is powered on and then changes to a high level after the high speed system oscillator is stable.
rev. 1.20 44 ????st 2?? 201? rev. 1.20 45 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom therefore this fag will always be read as "1" by the application program after device power-on. the fag will be low when in the sleep or idle0 mode but after a wake- up has occurred, the fag will change to a high level after 128 clock cycles if the hxt oscillator is used and after 15~16 clock cycles if the hirc oscillator is used. bit 1 idlen : idle mode control 0: disable 1: enable this is the idle mode control bit and determines what happens when the halt instruction is executed. if this bit is high, when a halt instruction is executed, the device will enter the idle mode. in the idle mode the cpu will stop running but the system clock will continue to keep the peripheral functions operational, if the fsyson bit is high. if the fsyson bit is low, the cpu and the system clock will all stop in idle0 mode. if the bit is low, the device will enter the sleep mode when a halt instruction is executed. bit 0 hlclk : system clock selection 0: f h /2~f h /64 or f sub 1: f h this bit is used to select if the f h clock or the f h /2~f h /64 or f sub clock is used as the system clock. when the bit is high the f h clock will be selected and if low the f h /2~f h /64 or f sub clock will be selected. when system clock switches from the f h clock to the f sub clock and the f h clock will be automatically switched off to conserve power. name fsyson lvrf lrf wrf r/w r/w r/w r/w r/w por 0 x 0 0 "x": ?nknown bit 7 fsyson : f sys control in idle mode 0: disable 1: enable this bit is used to control whether the system clock is switched on or not in the idle mode. if this bit is set to "0", the system clock will be switched off in the idle mode. however, the system clock will be switched on in the idle mode when the fsyson bit is set to "1". bit 6~3 unimplemented, read as "0" bit 2 lvrf : lvr function reset fag described elsewhere. bit 1 lrf : lvr control register software reset fag described elsewhere. bit 0 wrf : wdt control register software reset fag described elsewhere.
rev. 1.20 44 ????st 2?? 201? rev. 1.20 45 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom f ast wake-up to minimise power consumption the device can enter the sleep or idle0 mode, where the system clock source to the device will be stopped. however when the device is woken up again, it can take a considerable time for the original system oscillator to restart, stabilise and allow normal operation to resume. to ensure the device is up and running as fast as possible a fast wake-up function is provided, which allows f sub , namely either the lxt or lirc oscillator, to act as a temporary clock to frst drive the system until the original system oscillator has stabilised. as the clock source for the fast wake-up function is f sub , the fast wake-up function is only available in the sleep1 and idle0 modes. when the device is woken up from the sleep0 mode, the fast wake-up function has no effect because the f sub clock is stopped. the fast wake-up enable/disable function is controlled using the fsten bit in the smod register. if the hxt oscillator is selected as the fast mode system clock, and if the fast wake-up function is enabled, then it will take one to two t sub clock cycles of the lirc or lxt oscillator for the system to wake-up. the system will then initially run under the f sub clock source until 128 hxt clock cycles have elapsed, at which point the hto fag will switch high and the system will switch over to operating from the hxt oscillator. if the hirc oscillator or lirc oscillator i s used as the system oscillator then it will take 15~16 clock cycles of the hirc or 1~2 cycles of the lirc to wake up the system from the sleep or idle0 mode. the fast wake-up bit, fsten will have no effect in these cases. system oscillator fsten bit wake-up time (sleep0 mode) wake-up time (sleep1 mode) wake-up time (idle0 mode) wake-up time (idle1 mode) hxt 0 12? hxt cycles 12? hxt cycles 1~2 hxt cycles 1 12? hxt cycles 1~2 f sub cycles (system r?ns with f sub frst for 128 hxt cycles and then switches over to r? n with the hxt clock) 1~2 hxt cycles hirc x 15~16 hirc cycles 15~16 hirc cycles 1~2 hirc cycles lirc x 1~2 lirc cycles 1~2 lirc cycles 1~2 lirc cycles lxt x 12? hxt cycles 1~2 lxt cycles 1~2 lxt cycles "x": dont care wake-up times note that if the watchdog timer is disabled, which means that the lxt and lirc are all both off, then there will be no fast wake-up function available when the device wake-up from the sleep0 mode.
rev. 1.20 46 ????st 2?? 201? rev. 1.20 4? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom op erating mode switching the device can switch between operating modes dynamically allowing the user to select the best performance/power ratio for the present task in hand. in this way microcontroller operations that do not require high performance can be executed using slower clocks thus requiring less operating current and prolonging battery life in portable applications. in simple terms, mode switching between the fast mode and slow mode is executed using the hlclk bit and cks2~cks0 bits in the smod register while mode switching from the fast/ slow modes to the sleep/idle modes is executed via the halt instruction. when a halt instruction is executed, whether the device enters the idle mode or the sleep mode is determined by the condition of the idlen bit in the smod register and the fsyson bit in the ctrl register. fast f sys =f h ~f h /64 f h on cpu r?n f sys on f sub on f tbc on slow f sys =f sub f sub on cpu r?n f sys on f h off f tbc on idle0 h?lt instr?ction exec?ted cpu stop idlen=1 fsyson=0 f sys off f sub on f tbc on idle1 h?lt instr?ction exec?ted cpu stop idlen=1 fsyson=1 f sys on f sub on f tbc on sleep1 h?lt instr?ction exec?ted cpu stop idlen=0 f sys off f sub on f tbc off wdt or lvd on sleep0 h?lt instr?ction exec?ted cpu stop idlen=0 f sys off f sub off f tbc off wdt & lvd off when the hlclk bit switches to a low level, which implies that clock source is switched from the high speed clock, f h , to the clock source, f h /2~f h /64 or f sub . if the clock is from the f sub , the high speed clock source will stop running to conserve power. when this happens, it must be noted that the f h /16 and f h /64 internal clock sources will also stop running, which may affect the operation of other internal functions such as the tms. the accompamying chart shows what happens when the device moves between the various operating modes.
rev. 1.20 46 ????st 2?? 201? rev. 1.20 4? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom fast mode to slow mode switching when running in the fast mode, which uses the high speed system oscillator, and therefore consumes more power, the system clock can switch to run in the slow mode by set the hlclk bit to "0" and set the cks2~cks0 bits to "000" or "001" in the smod register. this will then use the low speed system oscillator which will consume less power. users may decide to do this for certain operations which do not require high performance and can subsequently reduce power consumption. the slow mode is sourced from the lxt or lirc oscillator determined by the configuration option and therefore requires this oscillator to be stable before full mode switching occurs. this is monitored using the lto bit in the smod register. fast mode slow mode cks2~cks0 = 00xb & hlclk = 0 sleep0 mode idlen=0 h?lt instr?ction is exec?ted sleep1 mode idle0 mode idle1 mode wdt and lvd are all off idlen=0 h?lt instr?ction is exec?ted wdt or lvd is on idlen=1? fsyson=0 h?lt instr?ction is exec?ted idlen=1? fsyson=1 h?lt instr?ction is exec?ted
rev. 1.20 4? ????st 2?? 201? rev. 1.20 49 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom slow mode to fast mode switching in slow mode the system uses either the lxt or lirc low speed system oscillator. to switch back to the fast mode, where the high speed system oscillator is used, the hlclk bit should be set to "1" or hlclk bit is "0", but cks2~cks0 feld is set to "010", "011", "100", "101", "110" or "111". as a certain amount of time will be required for high speed system oscillator stabilization depends upon which high speed system oscillator type is used. fast mode slow mode cks2~cks0 000b or 001b as hlclk = 0 or hlclk = 1 sleep0 mode idlen=0 halt instruction is executed sleep1 mode idle0 mode idle1 mode wdt and lvd are all off idlen=0 halt instruction is executed wdt or lvd is on idlen=1, fsyson=0 halt instruction is executed idlen=1, fsyson=1 halt instruction is executed entering the sleep0 mode there is only one way for the device to enter the sleep0 mode and that is to execute the "halt" instruction in the application program with the idlen bit in the smod register equal to "0" and the wdt and lvd both off. when this instruction is executed under the conditions described above, the following will occur: ? the system clock, wdt clock and time base clock will be stopped and the application program will stop at the "halt" instruction. ? the data memory contents and registers will maintain their present condition. ? the wdt will be cleared and stopped no matter the wdt clock source orginates from the lxt or lirc oscillator. ? the i/o ports will maintain their present conditions. ? in the status register, the power down fag pdf will be set, and wdt timeout fag to will be cleared.
rev. 1.20 4? ????st 2?? 201? rev. 1.20 49 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom entering the sleep1 mode there is only one way for the device to enter the sleep1 mode and that is to execute the "halt" instruction in the application program with the idlen bit in the smod register equal to "0" and the wdt or lvd on. when this instruction is executed under the conditions described above, the following will occur: ? the system clock and time base clock will be stopped and the application program will stop at the "halt" instruction, but the wdt or lvd will remain with the clock source coming from the f sub clock. ? the data memory contents and registers will maintain their present condition. ? the wdt will be cleared and resume counting if the wdt function is enabled. ? the i/o ports will maintain their present conditions. ? in the status register, the power down fag pdf will be set, and wdt timeout fag to will be cleared. entering the idle0 mode there is only one way for the device to enter the idle0 mode and that is to execute the "halt" instruction in the application program with the idlen bit in the smod register equal to "1" and the fsyson bit in the ctrl register equal to "0". when this instruction is executed under the conditions described above, the following will occur: ? the system clock will be stopped and the application program will stop at the "halt" instruction, but the f tbc and f sub clocks will be on. ? the data memory contents and registers will maintain their present condition. ? the wdt will be cleared and resume counting if the wdt function is enabled. ? the i/o ports will maintain their present conditions. ? in the status register, the power down fag pdf will be set, and wdt timeout fag to will be cleared. entering the idle1 mode there is only one way for the device to enter the idle1 mode and that is to execute the "halt" instruction in the application program with the idlen bit in the smod register equal to "1" and the fsyson bit in the ctrl register equal to "1". when this instruction is executed under the conditions described above, the following will occur: ? the system clock, f tbc and f sub clocks will be on but the application program will stop at the "halt" instruction. ? the data memory contents and registers will maintain their present condition. ? the wdt will be cleared and resume counting if the wdt function is enabled. ? the i/o ports will maintain their present conditions. ? in the status register, the power down fag pdf will be set, and wdt timeout fag to will be cleared.
rev. 1.20 50 ????st 2?? 201? rev. 1.20 51 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom standby current considerations as the main reason for entering the sleep or idle mode is to keep the current consumption of the device to as low a value as possible, perhaps only in the order of several micro-amps except in the idle1 mode, there are other considerations which must also be taken into account by the circuit designer if the power consumption is to be minimised. special attention must be made to the i/o pins on the device. all high-impedance input pins must be connected to either a fxed high or low level as any foating input pins could create internal oscillations and result in increased current consumption. this also applies to the device which has different package types, as there may be unbonbed pins. these must either be setup as outputs or if setup as inputs must have pull-high resistors connected. care must also be taken with the loads, which are connected to i/o pins, which are setup as outputs. these should be placed in a condition in which minimum current is drawn or connected only to external circuits that do not draw current, such as other cmos inputs. also note that additional standby current will also be required if the lirc oscillator has enabled. in the idle1 mode the system oscillator is on, if the system oscillator is from the high speed oscillator, the additional standby current will also be perhaps in the order of several hundred micro- amps. wake-up to minimise power consumption the device can enter the sleep or any idle mode, where the cpu will be switched off. however, when the device is woken up again, it will take a considerable time for the original system oscillator to restart, stablise and allow normal operation to resume. after the system enters the sleep or idle mode, it can be woken up from one of various sources listed as follows: ? an external falling edge on port a ? a system interrupt ? a wdt overfow when the device executes the "halt" instruction, it will enter the power down mode and the pdf fag will be set to 1. the pdf fag will be cleared to 0 if the device experiences a system power-up or executes the clear watchdog timer instruction. if the system is woken up by a wdt overfow, a watchdog timer reset will be initiated and the to fag will be set to 1. the to fag is set if a wdt time-out occurs and causes a wake-up that only resets the program counter and stack pointer, other fags remain in their original status. each pin on port a can be setup using the pawu register to permit a negative transition on the pin to wake up the system. when a port a pin wake-up occurs, the program will resume execution at the instruction following the "halt" instruction. if the system is woken up by an interrupt, then two possible situations may occur. the frst is where the related interrupt is disabled or the interrupt is enabled but the stack is full, in which case the program will resume execution at the instruction following the "halt" instruction. in this situation, the interrupt which woke up the device will not be immediately serviced, but will rather be serviced later when the related interrupt is fnally enabled or when a stack level becomes free. the other situation is where the related interrupt is enabled and the stack is not full, in which case the regular interrupt response takes place. if an interrupt request flag is set high before entering the sleep or idle mode, the wake-up function of the related interrupt will be disabled.
rev. 1.20 50 ????st 2?? 201? rev. 1.20 51 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom p rogramming considerations the high speed and low speed oscillators both use the same sst counter. for example, if the system is woken up from the sleep0 mode and both the hirc and lxt oscillators need to start-up from an off state. the lxt oscillator uses the sst counter after the hirc oscillator has fnished its sst period. ? if the device is woken up from the sleep0 mode to the fast mode, the high speed system oscillator needs an sst period. the device will execute frst instruction after hto is "1". at this time, the lxt oscillator may not be stability if f sub is from lxt oscillator. the same situation occurs in the power-on state. the lxt oscillator is not ready yet when the frst instruction is executed. ? if the device is woken up from the sleep1 mode to fast mode, and the system clock source is from the hxt oscillator and fsten is "1", the system clock can be switched to the lirc oscillator after wake up. ? there are peripheral functions, such as wdt and tms, for which the f sys is used. if the system clock source is switched from f h to f sub , the clock source to the peripheral functions mentioned above will change accordingly. ? the on/off condition of f sub and f s depends upon whether the wdt is enabled or disabled as the wdt clock source is selected from f sub .
rev. 1.20 52 ????st 2?? 201? rev. 1.20 53 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom watchdog timer the watchdog timer is provided to prevent program malfunctions or sequences from jumping to unknown locations, due to certain uncontrollable external events such as electrical noise. watchdog timer clock source the watchdog timer clock source is provided by the internal clock, f sub , which is in turn supplied by the lirc or lxt oscillator. the lxt oscillator is supplied by an external 32.768 khz crystal. the lirc internal oscillator has an approximate frequency of 32 khz at a supply voltage of 5v. however, it should be noted that this specifed internal clock frequency can vary with v dd , temperature and process variations. the watchdog timer source clock is then subdivided by a ratio of 2 8 to 2 18 to give longer timeouts, the actual value being chosen using the ws2~ws0 bits in the wdtc register. watchdog timer control register a single register, wdtc, controls the required timeout period as well as the enable/disable operation. this register controls the overall operation of the watchdog timer. wdtc register bit 7 6 5 4 3 2 1 0 name we4 we3 we2 we1 we0 ws2 ws1 ws0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 1 0 1 0 0 1 1 bit 7~3 : wdt function enable control 10101: disabled 01010: enabled other values: reset mcu if these bits are changed due to adverse environmental conditions, the microcontroller will be reset. the reset operation will be activated after a delay time,t sreset and the wrf bit in the ctrl register will be set to 1. bit 2~0 : wdt time-out period selection 000: 2 8 /f sub 001: 2 10 /f sub 010: 2 12 /f sub 011: 2 14 /f sub 100: 2 15 /f sub 101: 2 16 /f sub 110: 2 17 /f sub 111: 2 18 /f sub these three bits determine the division ratio of the watchdog timer source clock, which in turn determines the time-out period. ctrl register bit 7 6 5 4 3 2 1 0 name fsyson lvrf lrf wrf r/w r/w r/w r/w r/w por 0 x 0 0 "x": ?nknown bit 7 : f sys control in idle mode described elsewhere. bit 6~3 unimplemented, read as "0" bit 2 : lvr function reset fag described elsewhere.
rev. 1.20 52 ????st 2?? 201? rev. 1.20 53 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom bit 1 lrf : lvr control register software reset fag described elsewhere. bit 0 wrf : wdt control register software reset fag 0: not occurred 1: occurred this bit is set to 1 by the wdt control register software reset and cleared by the application program. note that this bit can only be cleared to 0 by the application program. watchdog timer operation the watchdog timer operates by providing a device reset when its timer overfows. this means that in the application program and during normal operation the user has to strategically clear the watchdog timer before it overfows to prevent the watchdog timer from executing a reset. this is done using the clear watchdog instruction. if the program malfunctions for whatever reason, jumps to an unknown location, or enters an endless loop, the clear instruction will not be executed in the correct manner, in which case the watchdog timer will overfow and reset the device. with regard to the watchdog timer enable/disable function, there are fve bits, we4~we0, in the wdtc register to offer the enable/disable control and reset control of the watchdog timer. the wdt function will be disabled when the we4~we0 bits are set to a value of 10101b while the wdt function will be enabled if the we4~we0 bits are equal to 01010b. if the we4~we0 bits are set to any other values, except 01010b and 10101b, it will reset the device after a delay time,t sreset . after power on these bits will have a value of 01010b. we4 ~ we0 bits wdt function 10101b disable 01010b enable ?ny other val?e reset mcu watchdog timer enable/disable control under normal program operation, a watchdog timer time-out will initialise a device reset and set the status bit to. however, if the system is in the sleep or idle mode, when a watchdog timer time-out occurs, the to bit in the status register will be set and only the program counter and stack pointer will be reset. three methods can be adopted to clear the contents of the watchdog timer. the frst is a wdt reset, which means a certain value except 01010b and 10101b written into the we4~we0 feld, the second is using the watchdog timer software clear instruction and the third is via a halt instruction. there is only one method of using software instruction to clear the watchdog timer. that is to use the single "clr wdt" instruction to clear the wdt contents. the maximum time out period is when the 2 18 division ratio is selected. as an example, with a 32 khz lirc oscillator as its source clock, this will give a maximum watchdog period of around 8 second for the 2 18 division ratio and a minimum timeout of 8ms for the 2 8 division ration. clr wdt instr?ction ?-sta?e divider wdt prescaler we4~we0 bits wdtc re?ister reset mcu f sub f sub /2 ? ?-to-1 mux clr ws2~ws0 (f sub /2 ? ~ f sub /2 1? ) wdt time-o?t (2 ? /f sub ~ 2 1? /f sub ) h?lt instr?ction watchdog timer
rev. 1.20 54 ????st 2?? 201? rev. 1.20 55 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom reset and initialisation a reset function is a fundamental part of any microcontroller ensuring that the device can be set to some predetermined condition irrespective of outside parameters. the most important reset condition is after power is frst applied to the microcontroller. in this case, internal circuitry will ensure that the microcontroller, after a short delay, will be in a well defined state and ready to execute the frst program instruction. after this power-on reset, certain important internal registers will be set to defned states before the program commences. one of these registers is the program counter, which will be reset to zero forcing the microcontroller to begin program execution from the lowest program memory address. in addition to the power-on reset, another reset exists in the form of a low voltage reset, lvr, where a full reset is implemented in situations where the power supply voltage falls below a certain threshold. another type of reset is when the watchdog timer overflows and resets the microcontroller. all types of reset operations result in different register conditions being setup. reset functions there are fve ways in which a microcontroller reset can occur, through events occurring internally. power-on reset the most fundamental and unavoidable reset is the one that occurs after power is frst applied to the microcontroller. as well as ensuring that the program memory begins execution from the frst memory address, a power-on reset also ensures that certain other registers are preset to known conditions. all the i/o port and port control registers will power up in a high condition ensuring that all pins will be frst set to inputs. v dd power-on reset sst time-o?t t rstd note: t rstd is power-on delay with typical time=50 ms power-on reset timing chart low voltage reset C lvr the microcontroller contains a low voltage reset circuit in order to monitor the supply voltage of the device. the lvr function is always enabled with a specifc lvr voltage, v lvr . if the supply voltage of the device drops to within a range of 0.9v~v lvr such as might occur when changing the battery, the lvr will automatically reset the device internally and the lvrf bit in the ctrl register will also be set to 1. for a valid lvr signal, a low supply voltage, i.e., a voltage in the range between 0.9v~ v lvr must exist for a time greater than that specifed by t lvr in the lvd/lvr characteristics. if the low supply voltage state does not exceed this value, the lvr will ignore the low supply voltage and will not perform a reset function. the actual v lvr value can be selected by the lvs7~lvs0 bits in the lvrc register. if the lvs7~lvs0 bits have any other value, which may perhaps occur due to adverse environmental conditions such as noise, the lvr will reset the device after a delay time,t sreset . when this happens, the lrf bit in the ctrl register will be set to 1. after power on the register will have the value of 01010101b. note that the lvr function will be automatically disabled when the device enters the power down mode.
rev. 1.20 54 ????st 2?? 201? rev. 1.20 55 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom lvr internal reset t rstd + t sst note: t rstd is power-on delay with typical time=50 ms low voltage reset timing chart ? lvrc register bit 7 6 5 4 3 2 1 0 name lvs ? lvs6 lvs5 lvs4 lvs3 lvs2 lvs1 lvs0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 1 0 1 0 1 0 1 bit 7~0 lvs7~lvs0 : lvr voltage select 01010101: 2.1v 00110011: 2.55v 10011001: 3.15v 10101010: 3.8v other values: generates a mcu reset C register is reset to por value when an actual low voltage condition occurs, as specifed by one of the four defned lvr voltage value above, an mcu reset will generated. the reset operation will be activated after the low voltage condition keeps more than a t lvr time. in this situation the register contents will remain the same after such a reset occurs. any register value, other than the four defned register values above, will also result in the generation of an mcu reset. the reset operation will be activated after a delay time,t sreset . however, in this situation the register contents will be reset to the por value. ? ctrl register bit 7 6 5 4 3 2 1 0 name fsyson lvrf lrf wrf r/w r/w r/w r/w r/w por 0 x 0 0 "x": ?nknown bit 7 fsyson : f control in idle mode described elsewhere. bit 6~3 unimplemented, read as "0" bit 2 lvrf : lvr function reset fag 0: not occurred 1: occurred this bit is set to 1 when a specifc low voltage reset condition occurs. note that this bit can only be cleared to 0 by the application program. bit 1 lrf : lvr control register software reset fag 0: not occurred 1: occurred this bit is set to 1 by the lvrc control register contains any undefned lvr voltage register values. this in effect acts like a software-reset function. note that this bit can only be cleared to 0 by the application program. bit 0 wrf : wdt control register software reset fag described elsewhere.
rev. 1.20 56 ????st 2?? 201? rev. 1.20 5? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom watchdog time-out reset during normal operation the watchdog time-out reset during normal operations in the fast or slow mode is the same as the hardware low voltage reset except that the watchdog time-out fag to will be set to "1". wdt time-o?t internal reset t rstd + t sst note: t rstd is power-on delay with typical time=16.7 ms wdt time-out reset during normal operation timing chart watchdog time-out reset during sleep or idle mode the watchdog time-out reset during sleep or idle mode is a little different from other kinds of reset. most of the conditions remain unchanged except that the program counter and the stack pointer will be cleared to "0" and the to fag will be set to "1". refer to the system start up time characteristics for t sst details. wdt time-o?t internal reset t sst wdt time-out reset during sleep or idle mode timing chart reset initial conditions the different types of reset described affect the reset fags in different ways. these fags, known as pdf and to are located in the status register and are controlled by various microcontroller operations, such as the sleep or idle mode function or watch dog timer. the reset flags are shown in the table: to pdf reset function 0 0 power-on reset ? ? lvr reset d ?rin? f ? st or slow mode operation 1 ? wdt time-o ?t reset d?rin? f ? st or slow mode operation 1 1 wdt time-o ?t reset d?rin? idle or sleep mode operation "?" stands for ?nchan?ed the following table indicates the way in which the various components of the microcontroller are affected after a power-on reset occurs. item reset function pro?ram co?nter reset to zero interr?pts ?ll interr?pts will be disabled wdt ? time bases clear after reset? wdt be?ins co?ntin? timer mod ?les timer mod ?les will be t? rned off inp?t/o?tp?t ports i/o ports will be set?p as inp?ts stack pointer stack pointer will point to the top of the stack the different kinds of resets all affect the internal registers of the microcontroller in different ways. to ensure reliable continuation of normal program execution after a reset occurs, it is important to know what condition the microcontroller is in after a particular reset occurs. the following table describes how each type of reset affects the microcontroller internal registers. note that where more than one package type exists the table will refect the situation for the larger package type.
rev. 1.20 56 ????st 2?? 201? rev. 1.20 5? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom register reset (power on) lvr reset wdt time-out (fast) wdt time-out (idle/sleep) i?r0 ---- ---- ---- ---- ---- ---- ---- ---- mp0 xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? i?r1 ---- ---- ---- ---- ---- ---- ---- ---- mp1 xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? bp ---- --0 ---- --0 ---- --0 ---- ---? ?cc xxxx xxxx ???? ???? ???? ???? ???? ???? pcl 0000 0000 0000 0000 0000 0000 0000 0000 tblp xxxx xxxx ???? ???? ???? ???? ???? ???? tblh xxxx xxxx ???? ???? ???? ???? ???? ???? tbhp ---- -xxx ---- - ??? ---- - ??? ---- - ??? st ? tus --00 xxxx --?? ???? --1? ???? --11 ???? smod 0000 0011 0000 0011 0000 0011 ???? ???? lvdc --00 -000 --00 -000 --00 -000 --?? -??? integ ---- 0000 ---- 0000 ---- 0000 ---- ???? intc0 -0-0 0-00 -0-0 0-00 -0-0 0-00 -?-? ?-?? intc1 0000 0000 0000 0000 0000 0000 ???? ???? intc2 0000 0000 0000 0000 0000 0000 ???? ???? mfi0 --00 --00 --00 --00 --00 --00 --?? --?? mfi1 --00 --00 --00 --00 --00 --00 --?? --?? mfi2 --00 --00 --00 --00 --00 --00 --?? --?? p? 1111 1111 1111 1111 1111 1111 ???? ???? p? c 1111 1111 1111 1111 1111 1111 ???? ???? p ?pu 0000 0000 0000 0000 0000 0000 ???? ???? p? wu 0000 0000 0000 0000 0000 0000 ???? ???? tmpc 0--- --00 0--- --00 0--- --00 ? --- --?? wdtc 0101 0011 0101 0011 0101 0011 ???? ???? tbc 0011 0111 0011 0111 0011 0111 ???? ???? ctrl 0--- -x00 0--- -100 0--- -000 ? --- -??? lvrc 0101 0101 0101 0101 0101 0101 ???? ???? ee? --00 0000 --00 0000 --00 0000 --?? ???? eed 0000 0000 0000 0000 0000 0000 ???? ???? s?dol xxxx ---- xxxx ---- xxxx ---- ???? ---- (?drfs=0) ???? ???? (?drfs=1) s?doh xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? (?drfs=0) ---- ???? (?drfs=1) s?dc0 0000 -000 0000 -000 0000 -000 ???? -??? s?dc1 000- -000 000- -000 000- -000 ???- -??? s?dc2 0000 0000 0000 0000 0000 0000 ???? ???? pb -111 1111 -111 1111 -111 1111 -??? ???? pbc -111 1111 -111 1111 -111 1111 -??? ???? pbpu -000 0000 -000 0000 -000 0000 -??? ???? tm0c0 0000 0--- 0000 0--- 0000 0--- ???? ?--- tm0c1 0000 0000 0000 0000 0000 0000 ???? ???? tm0dl 0000 0000 0000 0000 0000 0000 ???? ????
rev. 1.20 5? ????st 2?? 201? rev. 1.20 59 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom register reset (power on) lvr reset wdt time-out (fast) wdt time-out (idle/sleep) tm0dh ---- --00 ---- --00 ---- --00 ---- -- ?? tm0?l 0000 0000 0000 0000 0000 0000 ???? ???? tm0?h ---- --00 ---- --00 ---- --00 ---- -- ?? tm0rpl 0000 0000 0000 0000 0000 0000 ???? ???? tm0rph ---- --00 ---- --00 ---- --00 ---- -- ?? tm1c0 0000 0--- 0000 0--- 0000 0--- ???? ?--- tm1c1 0000 0000 0000 0000 0000 0000 ???? ???? tm1dl 0000 0000 0000 0000 0000 0000 ???? ???? tm1dh ---- --00 ---- --00 ---- --00 ---- -- ?? tm1?l 0000 0000 0000 0000 0000 0000 ???? ???? tm1?h ---- --00 ---- --00 ---- --00 ---- -- ?? tm1rpl 0000 0000 0000 0000 0000 0000 ???? ???? tm1rph ---- --00 ---- --00 ---- --00 ---- -- ?? pc -111 1111 -111 1111 -111 1111 -??? ???? pcc -111 1111 -111 1111 -111 1111 -??? ???? pcpu -000 0000 -000 0000 -000 0000 -??? ???? ?cerl 1111 1111 1111 1111 1111 1111 ???? ???? simc0 111- 0000 111- 0000 111- 0000 ???- ???? simc1 1000 0001 1000 0001 1000 0001 ???? ???? simd xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? sim?/simc2 0000 0000 0000 0000 0000 0000 ???? ???? simtoc 0000 0000 0000 0000 0000 0000 ???? ???? slcdc0 0000 0000 0000 0000 0000 0000 ???? ???? slcdc1 0000 0000 0000 0000 0000 0000 ???? ???? slcdc2 0000 0000 0000 0000 0000 0000 ???? ???? slcdc3 0000 0000 0000 0000 0000 0000 ???? ???? sledc0 0101 0101 0101 0101 0101 0101 ???? ???? sledc1 ---- 0101 ---- 0101 ---- 0101 ---- ???? ifs0 --00 0000 --00 0000 --00 0000 --?? ???? ifs1 ---- 0000 ---- 0000 ---- 0000 ---- ???? usr 0000 1011 0000 1011 0000 1011 ???? ???? ucr1 0000 00x0 0000 00x0 0000 00x0 ???? ???? ucr2 0000 0000 0000 0000 0000 0000 ???? ???? brg xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? txr_rxr xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? eec ---- 0000 ---- 0000 ---- 0000 ---- ???? note: "u" stands for unchanged "x" stands for "unknown" "-" stands for unimplemented
rev. 1.20 5? ????st 2?? 201? rev. 1.20 59 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom input/output ports h oltek microcontrollers offer considerable fexibility on their i/o ports. with the input or output designation of every pin fully under user program control, pull-high selections for all ports and wake-up selections on certain pins, the user is provided with an i/o structure to meet the needs of a wide range of application possibilities. the device provides bidirectional input/output lines labeled with port names pa~pc. these i/o ports are mapped to the ram data memory with specifc addresses as shown in the special purpose data memory table. all of these i/o ports can be used for input and output operations. for input operation, these ports are non-latching, which means the inputs must be ready at the t2 rising edge of instruction "mov a, [m]", where m denotes the port address. for output operation, all the data is latched and remains unchanged until the output latch is rewritten. register name bit 7 6 5 4 3 2 1 0 p? wu p ? wu? p ? wu6 p ? wu5 p ? wu4 p ? wu3 p ? wu2 p ? wu1 p ? wu0 p? p ?? p? 6 p? 5 p? 4 p? 3 p? 2 p? 1 p? 0 p? c p ?c? p ?c6 p ?c5 p ?c4 p ?c3 p ?c2 p ?c1 p ?c0 p ?pu p ?pu? p ?pu6 p ?pu5 p ?pu4 p ?pu3 p ?pu2 p ?pu1 p ?pu0 pb pb6 pb5 pb4 pb3 pb2 pb1 pb0 pbc pbc6 pbc5 pbc4 pbc3 pbc2 pbc1 pbc0 pbpu pbpu6 pbpu5 pbpu4 pbpu3 pbpu2 pbpu1 pbpu0 pc pc6 pc5 pc4 pc3 pc2 pc1 pc0 pcc pcc6 pcc5 pcc4 pcc3 pcc2 pcc1 pcc0 pcpu pcpu6 pcpu5 pcpu4 pcpu3 pcpu2 pcpu1 pcpu0 " C ": unimplemented? read as "0" i/o logic function registers list pull-high resistors many product applications require pull-high resistors for their switch inputs usually requiring the use of an external resistor. to eliminate the need for these external resistors, all i/o pins, when confgured as an input have the capability of being connected to an internal pull-high resistor. these pull-high resistors are selected using the relevant pull-high control registers and are implemented using weak pmos transistors. pxpu register bit 7 6 5 4 3 2 1 0 name pxpu? pxpu4 pxpu5 pxpu4 pxpu3 pxpu2 pxpu1 pxpu0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 pxpun : i/o port x pin pull-high function control 0: disable 1: enable the pxpun bit is used to control the pin pull-high function. here the "x" can be a, b or c. however, the actual available bits for each i/o port may be different.
rev. 1.20 60 ????st 2?? 201? rev. 1.20 61 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom port a wake-up the halt instruction forces the microcontroller into the sleep or idle mode which preserves power, a feature that is important for battery and other low-power applications. various methods exist to wake-up the microcontroller, one of which is to change the logic condition on one of the port a pins from high to low. this function is especially suitable for applications that can be woken up via external switches. each pin on port a can be selected individually to have this wake-up feature using the pawu register. pawu register bit 7 6 5 4 3 2 1 0 name p ? wu? p ? wu6 p ? wu5 p ? wu4 p ? wu3 p ? wu2 p ? wu1 p ? wu0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~0 pawu7~pawu0 : pa7~pa0 wake-up function control 0: disable 1: enable i/o port control registers each port has its own control register, known as pac~pcc, which controls the input/output configuration. with this control register, each i/o pin with or without pull-high resistors can be reconfigured dynamically under software control. for the i/o pin to function as an input, the corresponding bit of the control register must be written as a "1". this will then allow the logic state of the input pin to be directly read by instructions. when the corresponding bit of the control register is written as a "0", the i/o pin will be setup as a cmos output. if the pin is currently setup as an output, instructions can still be used to read the output register. however, it should be noted that the program will in fact only read the status of the output data latch and not the actual logic status of the output p in. pxc register bit 7 6 5 4 3 2 1 0 name pxc? pxc5 pxc5 pxc4 pxc3 pxc2 pxc1 pxc0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 1 1 1 1 1 1 1 1 pxcn : i/o port x pin type selection 0: output 1: input the pxcn bit is used to control the pin type selection. here the "x" can be a, b or c. however, the actual available bits for each i/o port may be different.
rev. 1.20 60 ????st 2?? 201? rev. 1.20 61 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom i/o port source current control the device supports different source current driving capability for each i/o port. with the corresponding selection register, sledc0 and sledc1, each i/o port can support four levels of the source current driving capability. users should refer to the input/output characteristics section to select the desired source current for different applications. register name bit 7 6 5 4 3 2 1 0 sledc0 pbps3 pbps2 pbps1 pbps0 p ?ps3 p ?ps2 p ?ps1 p ?ps0 sledc1 pcps3 pcps2 pcps1 pcps0 i/o port source current control registers list sledc0 register bit 7 6 5 4 3 2 1 0 name pbps3 pbps2 pbps1 pbps0 p ?ps3 p ?ps2 p ?ps1 p ?ps0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 1 0 1 0 1 0 1 bit 7~6 pbps3~pbps2 : pb6~pb4 source current selection 00: source current=level 0 (min.) 01: source current=level 1 10: source current=level 2 11: source current=level 3 (max.) bit 5~4 pbps1~pbps0 : pb3~pb0 source current selection 00: source current=level 0 (min.) 01: source current=level 1 10: source current=level 2 11: source current=level 3 (max.) bit 3~2 paps3~paps2 : pa7~pa4 source current selection 00: source current=level 0 (min.) 01: source current=level 1 10: source current=level 2 11: source current=level 3 (max.) bit 1~0 paps1~paps0 : pa3~pa0 source current selection 00: source current=level 0 (min.) 01: source current=level 1 10: source current=level 2 11: source current=level 3 (max.) sledc1 register bit 7 6 5 4 3 2 1 0 name pcps3 pcps2 pcps1 pcps0 r/w r/w r/w r/w r/w por 0 1 0 1 bit 7~4 unimplemented, read as "0" bit 3~2 pcps3~pcps2 : pc6~pc4 source current selection 00: source current=level 0 (min.) 01: source current=level 1 10: source current=level 2 11: source current=level 3 (max.)
rev. 1.20 62 ????st 2?? 201? rev. 1.20 63 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom bit 1~0 pcps1~pcps0 : pc3~pc0 source current selection 00: source current=level 0 (min.) 01: source current=level 1 10: source current=level 2 11: source current=level 3 (max.) pin -remapping function the fexibility of the microcontroller range is greatly enhanced by the use of pins that have more than one function. limited numbers of pins can force serious design constraints on designers but by supplying pins with multi-functions, many of these difficulties can be overcome. the way in which the pin function of each pin is selected is different for each function and a priority order is established where more than one pin function is selected simultaneously. additionally there are two registers, ifs0 and ifs1, to establish certain pin functions. the limited number of supplied pins in a package can impose restrictions on the amount of functions a certain device can contain. however by allowing the same pins to share several different functions and providing a means of function selectio n, a wide range of different functions can be incorporated into even relatively small package sizes. if the pin-shared pin function have multiple outputs simultaneously, its pin names at the right side of the "/" sign can be used for higher priority. ifs0 register bit 7 6 5 4 3 2 1 0 name sdops sdi_sd?ps sck_sclps scsbps int1ps int0ps r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 bit 7~6 unimplemented, read as "0" bit 5 sdops : sdo pin-remapping selection 0: sdo on pc2 1: sdo on pa2 bit 4 sdi_sdaps : sdi/sda pin-remapping selection 0: sdi/sda on pc3 1: sdi/sda on pa3 bit 3 sck_sclps : sck/scl pin-remapping selection 0: sck/scl on pc4 1: sck/scl on pb6 bit 2 scsbps : scs pin-remapping selection 0: scs on pa1 1: scs on pb5 bit 1 int1ps : int1 pin-remapping selection 0: int1 on pb1 1: int1 on pc5 bit 0 int0ps : int0 pin-remapping selection 0: int0 on pb0 1: int0 on pc6
rev. 1.20 62 ????st 2?? 201? rev. 1.20 63 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom ifs1 register bit 7 6 5 4 3 2 1 0 name tck1ps tck0ps txps rxps r/w r/w r/w r/w r/w por 0 0 0 0 bit 7~4 unimplemented, read as "0" bit 3 tck1ps : tck1 pin-remapping selection 0: tck1 on pa4 1: tck1 on pa6 bit 2 tck0ps : tck0 pin-remapping selection 0: tck0 on pb2 1: tck0 on pa5 bit 1 txps : tx pin-remapping selection 0: tx on pc6 1: tx on pb3 bit 0 rxps : rx pin-remapping selection 0: rx on pc5 1: rx on pb4 i/o pin structures the accompanying diagram illustrates the internal structure of the i/o logic function. as the exact logical construction of the i/o pin will differ from this drawing, it is supplied as a guide only to assist with the functional understanding of the i/o logic function. the wide range of pin-shared structures does not permit all types to be shown. m u x vdd control bit data bit data b?s write control re?ister chip reset read control re?ister read data re?ister write data re?ister system wake-?p wake-?p select i/o pin weak p?ll-?p p?ll-hi?h re?ister select q d ck q d ck q q s s p? only logic function input/output structure
rev. 1.20 64 ????st 2?? 201? rev. 1.20 65 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom programming considerations within the user program, one of the things frst to consider is port initialisation. after a reset, all of the i/o data and port control registers will be set to high. this means that all i/o pins will be defaulted to an input state, the level of which depends on the other connected circuitry and whether pull-high selections have been chosen. if the port control registers are then programmed to setup some pins as outputs, these output pins will have an initial high output value unless the associated port data registers are frst programmed. selecting which pins are inputs and which are outputs can be achieved byte-wide by loading the correct values into the appropriate port control register or by programming individual bits in the port control register using the "set [m].i" and "clr [m].i" instructions. note that when using these bit control instructions, a read-modify-write operation takes place. the microcontroller must frst read in the data on the entire port, modify it to the required new bit values and then rewrite this data back to the output ports. port a has the additional capability of providing wake-up functions. when the device is in the sleep or idle mode, various methods are available to wake the device up. one of these is a high to low transition of any of the port a pins. single or multiple pins on port a can be setup to have this function.
rev. 1.20 64 ????st 2?? 201? rev. 1.20 65 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom timer modules C tm one of the most fundamental functions in any microcontroller device is the ability to control and measure time. to implement time related functions the device includes several timer modules, generally abbreviated to the name tm. the tms are multi-purpose timing units and serve to provide operations such as timer/counter, input capture, compare match output and single pulse output as well as being the functional unit for the generation of pwm signals. each of the tms has two interrupts. the addition of input and output pins for each tm ensures that users are provided with timing units with a wide and fexible range of features. introduction the device contains two tms categorised as periodic type tm having a reference name of tm0 and tm1. the main features of ptm is summarised in the accompanying table. tm function ptm timer/co ?nter inp?t capt?re compare match o?tp?t pwm channels 1 sin?le p?lse o?tp?t 1 pwm ?li?nment ed?e pwm ?dj?stment period & d?ty d?ty or period tm function summary the device contains a specifc number of periodic type tm unit which is shown in the table together with their individual reference name, tm0~tm1. tm0 tm1 10-bit ptm 10-bit ptm tm name/type reference tm operation the periodic type tms offer a diverse range of functions, from simple timing operations to pwm signal generation. the key to understanding how the tm operates is to see it in terms of a free running count-up counter whose value is then compared with the value of pre-programmed internal comparators. when the free running count-up counter has the same value as the pre-programmed comparator, known as a compare match situation, a tm interrupt signal will be generated which can clear the counter and perhaps also change the condition of the tm output pin. the internal tm counter is driven by a user selectable clock source, which can be an internal clock or an external pin. tm clock source the clock source which drives the main counter in each tm can originate from various sources. the selection of the required clock source is implemented using the tnck2~tnck0 bits in the tm control registers. the clock source can be a ratio of the system clock, f sys , or the internal high clock, f h , the f tbc clock source or the external tckn pin. the tckn pin clock source is used to allow an external signal to drive the tm as an external clock source for event counting.
rev. 1.20 66 ????st 2?? 201? rev. 1.20 6? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom tm interrupts the periodic type tm has two internal interrupt, one for each of the internal comparator a or comparator p, which generate a tm interrupt when a compare match condition occurs. when a tm interrupt is generated, it can be used to clear the counter and also to change the state of the tm output pin. tm external pins the periodic type tms each has one tm input pin, with the label tckn. the tm input pin is essentially a clock source for the tm and is selected using the tnck2~tnck0 bits in the tmnc0 register. this external tm input pin allows an external clock source to drive the internal tm. this external tm input pin is shared with other functions but will be connected to the internal tm if selected using the tnck2~tnck0 bits. the tm input pin can be chosen to have either a rising or falling active edge. the tckn pin is also used as the external trigger input pin in single pulse output mode for the ptm. the periodic type tms each has one output pin with the label tpn. when the tm is in the compare match output mode, these pins can be controlled by the tm to switch to a high or low level or to toggle when a compare match situation occurs. the external tpn output pin is also the pin where the tm generates the pwm output waveform. the tpn pin acts as an input when the tm is setup to operate in the capture input mode. as the tpn pins are pin-shared with other functions, the tpn pin function is enabled or disabled according to the internal tm on/off control, operation mode and output control settings. when the corresponding tm confguration selects the tpn pin to be used as an output pin, the associated pin will be setup as an external tm output pin. if the tm confguration selects the tpn pin to be setup as an input pin, the input signal supplied on the associated pin can be derived from an external signal and other pin-shared output function. if the tm confguration determines that the tpn pin function is not used, the associated pin will be controlled by other pin-shared functions. the details of the tpn pin for each tm type and device are provided in the accompanying table. tm0(ptm) tm1(ptm) register tck0; tp0 tck1; tp1 tmpc tm external pins
rev. 1.20 66 ????st 2?? 201? rev. 1.20 6? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom tm input/output pin control register selecting to have a tm input/output or whether to retain its other shared function is implemented using the relevant tm pin function control register, with a single control bit in the pin function control register corresponding to a tm input/output pin. setting the specifc bit high will setup the corresponding pin as a tm input/output, if reset to low the pin will retain its original other function. tm0 (ptm) p?0/tp0 t0cp p?0 o?tp?t f?nction 0 1 0 1 o?tp?t capt?re inp?t 0 1 t0c?pts pb2/tck0 tck0 inp?t tck0ps 0 1 p?5/tck0 tm0 function pin control block diagram tm1 (ptm) p??/tp1 t1cp p?? o?tp?t f?nction 0 1 0 1 o?tp?t capt?re inp?t 0 1 t1c?pts p?4/tck1 tck1 inp?t tck1ps 0 1 p?6/tck1 tm1 function pin control block diagram tmpc register bit 7 6 5 4 3 2 1 0 name clop t1cp t0cp r/w r/w r/w r/w por 0 0 0 bit 7 clop : clo pin control 0: disable 1: enable bit 6~2 unimplemented, read as "0" bit 1 t1cp : tp1 pin control 0: disable 1: enable bit 0 t0cp : tp0 pin control 0: disable 1: enable
rev. 1.20 6? ????st 2?? 201? rev. 1.20 69 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom programming considerations the tm counter registers and the capture/compare ccra and ccrp registers, being either 10- bit or 16-bit, all have a low and high byte structure. the high bytes can be directly accessed, but as the low bytes can only be accessed via an internal 8-bit buffer, reading or writing to these register pairs must be carried out in a specifc way. the important point to note is that data transfer to and from the 8-bit buffer and its related low byte only takes place when a write or read operation to its corresponding high byte is executed. as the ccra and ccrp registers are implemented in the way shown in the following diagram and accessing these register pairs is carried out in a specifc way as described above, it is recommended to use the "mov" instruction to access the ccra and ccrp low byte registers, named tmnal and tmnrpl, using the following access procedures. accessing the ccra or ccrp low byte registers without following these access procedures will result in unpredictable values. data b?s ?-bit b?ffer tmndh tmndl tmn?h tmn?l tmn co?nter re?ister (read only) tmn ccr? re?ister (read/write) tmnrph tmnrpl ptm ccrp re?ister (read/write) the following steps show the read and write procedures: ? writing data to ccra or ccrp ? step 1. write data to low byte tmnal or tmnrpl C note that here data is only written to the 8-bit buffer. ? step 2. write data to high byte tmnah or tmnrph C here data is written directly to the high byte registers and simultaneously data is latched from the 8-bit buffer to the low byte registers. ? reading data from the counter registers and ccra or ccrp ? step 1. read data from the high byte tmndh, tmnah or tmnrph C here data is read directly from the high byte registers and simultaneously data is latched from the low byte register into the 8-bit buffer. ? step 2. read data from the low byte tmndl, tmnal or tmnrpl C this step reads data from the 8-bit buffer.
rev. 1.20 6? ????st 2?? 201? rev. 1.20 69 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom periodic type tm C ptm the periodic type tm contains fve operating modes, which are compare match output, timer/ event counter, capture input, single pulse output and pwm output modes. the periodic tm can also be controlled with one external input pin and can drive one external output pin. tm core tm no. tm input pin tm output pin 10-bit ptm tm0? tm1 tck0? tck1 tp0? tp1 f sys f sys /4 f h /64 f h /16 f tbc tckn 000 001 010 011 100 101 110 111 tnck2~tnck0 10-bit co?nt-?p co?nter 10-bit comparator p ccrp b0~b9 b0~b9 10-bit comparator ? tnon tnp?u comparator ? match comparator p match co?nter clear 0 1 o?tp?t control polarity control pin control tpn tnoc tnm1? tnm0 tnio1? tnio0 tn?f interr?pt tnpf interr?pt tnpol tncp ccr? tncclr ed?e detector tnio1? tnio0 f h 1 0 tnc?pts periodic type tm block diagram (n=0,1) note: the tckn external pins are remapping on different pins, so before using the tmn function, the pin-remapping function register ifs1 must be set properly. p eriodic tm operation the size of periodic tm is 10-bit wide and its core is a 10-bit count-up counter which is driven by a user selectable internal or external clock source. there are also two internal comparators with the names, comparator a and comparator p. these comparators will compare the value in the counter with ccrp and ccra registers. the ccrp and ccra comparators are 10-bit wide whose value is respectively compared with all counter bits. the only way of changing the value of the 10-bit counter using the application program is to clear the counter by changing the tnon bit from low to high. the counter will also be cleared automatically by a counter overfow or a compare match with one of its associated comparators. when these conditions occur, a tm interrupt signal will also usually be generated. the periodic type tm can operate in a number of different operational modes, can be driven by different clock sources including an input pin and can also control the output pins. all operating setup conditions are selected using relevant internal registers.
rev. 1.20 ?0 ????st 2?? 201? rev. 1.20 ?1 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom p eriodic type tm register description overall operation of the periodic tm is controlled using a series of registers. a read only register pair exists to store the internal counter 10-bit value, while two read/write register pairs exist to store the internal 10-bit ccra and ccrp value. the remaining two registers are control registers which setup the different operating and control modes. register name bit 7 6 6 4 3 2 1 0 tmnc0 tnp ?u tnck2 tnck1 tnck0 tnon tmnc1 tnm1 tnm0 tnio1 tnio0 tnoc tnpol tnc?pts tncclr tmndl d? d6 d5 d4 d3 d2 d1 d0 tmndh d9 d? tmn?l d? d6 d5 d4 d3 d2 d1 d0 tmn?h d9 d? tmnrpl tnrp? tnrp6 tnrp5 tnrp4 tnrp3 tnrp2 tnrp1 tnrp0 tmnrph tnrp9 tnrp? periodic tm registers list (n =0,1) tmndl register bit 7 6 5 4 3 2 1 0 name d? d6 d5 d4 d3 d2 d1 d0 r/w r r r r r r r r por 0 0 0 0 0 0 0 0 bit 7~0 tmn counter low byte register bit 7 ~ bit 0 tmn 10-bit counter bit 7 ~ bit 0 tmndh register bit 7 6 5 4 3 2 1 0 name d9 d? r/w r r por 0 0 bit 7~2 unimplemented, read as "0" bit 1~0 tmn counter high byte register bit 1 ~ bit 0 tmn 10-bit counter bit 9 ~ bit 8 tmnal register bit 7 6 5 4 3 2 1 0 name d? d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~0 tmn ccra low byte register bit 7 ~ bit 0 tmn 10-bit ccra bit 7 ~ bit 0
rev. 1.20 ?0 ????st 2?? 201? rev. 1.20 ?1 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom tmnah register bit 7 6 5 4 3 2 1 0 name d9 d? r/w r/w r/w por 0 0 bit 7~2 unimplemented, read as "0" bit 1~0 tmn ccra high byte register bit 1 ~ bit 0 tmn 10-bit ccra bit 9 ~ bit 8 tmnrpl register bit 7 6 5 4 3 2 1 0 name tnrp? tnrp6 tnrp5 tnrp4 tnrp3 tnrp2 tnrp1 tnrp0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~0 tnrp7~tnrp0 : tmn ccrp low byte register bit 7 ~ bit 0 tmn 10-bit ccrp bit 7 ~ bit 0 tmnrph register bit 7 6 5 4 3 2 1 0 name tnrp9 tnrp? r/w r/w r/w por 0 0 bit 7~2 unimplemented, read as "0" bit 1~0 tnrp9~tnrp8 : tmn ccrp high byte register bit 1 ~ bit 0 tmn 10-bit ccrp bit 9 ~ bit 8 tmnc0 register bit 7 6 5 4 3 2 1 0 name tnp ?u tnck2 tnck1 tnck0 tnon r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 bit 7 tnpau : tmn counter pause control 0: run 1: pause the counter can be paused by setting this bit high. clearing the bit to zero restores normal counter operation. when in a pause condition the tmn will remain powered up and continue to consume power. the counter will retain its residual value when this bit changes from low to high and resume counting from this value when the bit changes to a low value again. bit 6~4 tnck2~tnck0 : select tmn counter clock 000: f /4 001: f 010: f h /16 011: f h /64 100: f tbc 101: f h 110: tckn rising edge clock 111: tckn falling edge clock these three bits are used to select the clock source for the tmn. the external pin clock source can be chosen to be active on the rising or falling edge. the clock source f is the system clock, while f h and f tbc are other internal clocks, the details of which can be found in the oscillator section.
rev. 1.20 ?2 ????st 2?? 201? rev. 1.20 ?3 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom bit 3 tnon : tmn counter on/off control 0: off 1: on this bit controls the overall on/off function of the tmn. setting the bit high enables the counter to run while clearing the bit disables the tmn. clearing this bit to zero will stop the counter from counting and turn off the tmn which will reduce its power consumption. when the bit changes state from low to high the internal counter value will be reset to zero, however when the bit changes from high to low, the internal counter will retain its residual value until the bit returns high again. if the tmn is in the compare match output mode then the tmn output pin will be reset to its initial condition, as specifed by the tnoc bit, when the tnon bit changes from low to high. bit 2~0 unimplemented, read as "0" tmnc1 register bit 7 6 5 4 3 2 1 0 name tnm1 tnm0 tnio1 tnio0 tnoc tnpol tnc?pts tncclr r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~6 tnm1~tnm0 : select tmn operating mode 00: compare match output mode 01: capture input mode 10: pwm mode or single pulse output mode 11: timer/counter mode these bits setup the required operating mode for the tmn. to ensure reliable operation the tmn should be switched off before any changes are made to the tnm1 and tnm0 bits. in the timer/counter mode, the tmn output pin control will be disabled. bit 5~4 tnio1~tnio0 : select tmn external pin tpn function compare match output mode 00: no change 01: output low 10: output high 11: toggle output pwm output mode/single pulse output mode 00: pwm output inactive state 01: pwm output active state 10: pwm output 11: single pulse output capture input mode 00: input capture at rising edge of tpn or tckn 01: input capture at falling edge of tpn or tckn 10: input capture at rising/falling edge of tpn or tckn 11: input capture disabled timer/counter mode unused these two bits are used to determine how the tmn output pin changes state when a certain condition is reached. the function that these bits select depends upon in which mode the tmn is running.
rev. 1.20 ?2 ????st 2?? 201? rev. 1.20 ?3 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom in the compare match output mode, the tnio1 and tnio0 bits determine how the tmn output pin changes state when a compare match occurs from the comparator a. the tmn output pin can be setup to switch high, switch low or to toggle its present state when a compare match occurs from the comparator a. when the bits are both zero, then no change will take place on the output. the initial value of the tmn output pin should be setup using the tnoc bit in the tmnc1 register. note that the output level requested by the tnio1 and tnio0 bits must be different from the initial value setup using the tnoc bit otherwise no change will occur on the tmn output pin when a compare match occurs. after the tmn output pin changes state, it can be reset to its initial level by changing the level of the tnon bit from low to high. in the pwm mode, the tnio1 and tnio0 bits determine how the tmn output pin changes state when a certain compare match condition occurs. the tmn output function is modified by changing these two bits. it is necessary to only change the values of the tnio1 and tnio0 bits only after the tmn has been switched off. unpredictable pwm outputs will occur if the tnio1 and tnio0 bits are changed when the tmn is running. bit 3 tnoc : tmn tpn output control compare match output mode 0: initial low 1: initial high pwm output mode/single pulse output mode 0: active low 1: active high this is the output control bit for the tmn output pin. its operation depends upon whether tmn is being used in the compare match output mode or in the pwm mode/ single pulse output mode. it has no effect if the tmn is in the timer/counter mode. in the compare match output mode it determines the logic level of the tmn output pin before a compare match occurs. in the pwm mode/single pulse output mode it determines if the pwm signal is active high or active low. bit 2 tnpol : tmn tpn output polarity control 0: non-inverted 1: inverted this bit controls the polarity of the tpn output pin. when the bit is set high the tmn output pin will be inverted and not inverted when the bit is zero. it has no effect if the tmn is in the timer/counter mode. bit 1 tncapts : tmn capture triiger source selection 0: from tpn pin 1: from tckn pin bit 0 tncclr : tmn counter clear condition selection 0: comparator p match 1: comparator a match this bit is used to select the method which clears the counter. remember that the periodic tm contains two comparators, comparator a and comparator p, either of which can be selected to clear the internal counter. with the tncclr bit set high, the counter will be cleared when a compare match occurs from the comparator a. when the bit is low, the counter will be cleared when a compare match occurs from the comparator p or with a counter overfow. a counter overfow clearing method can only be implemented if the ccrp bits are all cleared to zero. the tncclr bit is not used in the pwm output, single pulse output or capture input mode.
rev. 1.20 ?4 ????st 2?? 201? rev. 1.20 ?5 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom p eriodic type tm operation modes the periodic type tm can operate in one of fve operating modes, compare match output mode, pwm output mode, single pulse output mode, capture input mode or timer/counter mode. the operating mode is selected using the tnm1 and tnm0 bits in the tmnc1 register. compare match output mode to select this mode, bits tnm1 and tnm0 in the tmnc1 register, should be set to 00 respectively. in this mode once the counter is enabled and running it can be cleared by three methods. these are a counter overfow, a compare match from comparator a and a compare match from comparator p. when the tncclr bit is low, there are two ways in which the counter can be cleared. one is when a compare match from comparator p, the other is when the ccrp bits are all zero which allows the counter to overfow. here both tnaf and tnpf interrupt request fags for comparator a and comparator p respectively, will both be generated. if the tncclr bit in the tmnc1 register is high then the counter will be cleared when a compare match occurs from comparator a. however, here only the tnaf interrupt request flag will be generated even if the value of the ccrp bits is less than that of the ccra registers. therefore when tncclr is high no tnpf interrupt request fag will be generated. in the compare match output mode, the ccra can not be set to "0". as the name of the mode suggests, after a comparison is made, the tmn output pin will change state. the tmn output pin condition however only changes state when a tnaf interrupt request fag is generated after a compare match occurs from comparator a. the tnpf interrupt request fag, generated from a compare match occurs from comparator p, will have no effect on the tmn output pin. the way in which the tmn output pin changes state are determined by the condition of the tnio1 and tnio0 bits in the tmnc1 register. the tmn output pin can be selected using the tnio1 and tnio0 bits to go high, to go low or to toggle from its present condition when a compare match occurs from comparator a. the initial condition of the tmn output pin, which is setup after the tnon bit changes from low to high, is setup using the tnoc bit. note that if the tnio1 and tnio0 bits are zero then no pin change will take place.
rev. 1.20 ?4 ????st 2?? 201? rev. 1.20 ?5 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom co?nter val?e 0x3ff ccrp ccr? tnon tnp?u tnpol ccrp int. fla? tnpf ccr? int. fla? tn?f tmn o/p pin time ccrp=0 ccrp > 0 co?nter overflow ccrp > 0 co?nter cleared by ccrp val?e pa?se res?me stop co?nter restart tncclr = 0; tnm [1:0] = 00 o?tp?t pin set to initial level low if tnoc=0 o?tp?t to??le with tn?f fla? note tnio [1:0] = 10 ?ctive hi?h o?tp?t select here tnio [1:0] = 11 to??le o?tp?t select o?tp?t not affected by tn?f fla?. remains hi?h ?ntil reset by tnon bit o?tp?t pin reset to initial val?e o?tp?t controlled by other pin-shared f?nction o?tp?t inverts when tnpol is hi?h compare match output mode C tncclr=0(n=0,1) note: 1. with tncclr=0, a comparator p match will clear the counter 2. the tmn output pin is controlled only by the tnaf fag 3. the output pin is reset to its initial state by a tnon bit rising edge
rev. 1.20 ?6 ????st 2?? 201? rev. 1.20 ?? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom co?nter val?e 0x3ff ccrp ccr? tnon tnp?u tnpol ccrp int. fla? tnpf ccr? int. fla? tn?f tmn o/p pin time ccr?=0 ccr? = 0 co?nter overflow ccr? > 0 co?nter cleared by ccr? val?e pa?se res?me stop co?nter restart tncclr = 1; tnm [1:0] = 00 o?tp?t pin set to initial level low if tnoc=0 o?tp?t to??le with tn?f fla? note tnio [1:0] = 10 ?ctive hi?h o?tp?t select here tnio [1:0] = 11 to??le o?tp?t select o?tp?t not affected by tn?f fla?. remains hi?h ?ntil reset by tnon bit o?tp?t pin reset to initial val?e o?tp?t controlled by other pin-shared f?nction o?tp?t inverts when tnpol is hi?h tnpf not ?enerated no tn?f fla? ?enerated on ccr? overflow o?tp?t does not chan?e compare match output mode C tncclr=1(n=0,1) note: 1. with tncclr=1, a comparator a match will clear the counter 2. the tmn output pin is controlled only by the tnaf fag 3. the output pin is reset to its initial state by a tnon bit rising edge 4. a tnpf fag is not generated when tncclr =1
rev. 1.20 ?6 ????st 2?? 201? rev. 1.20 ?? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom timer/counter mode to select this mode, bits tnm1 and tnm0 in the tmnc1 register should be set to 11 respectively. the timer/counter mode operates in an identical way to the compare match output mode generating the same interrupt fags. the exception is that in the timer/counter mode the tmn output pin is not used. therefore the above description and timing diagrams for the compare match output mode can be used to understand its function. as the tmn output pin is not used in this mode, the pin can be used as a normal i/o pin or other pin-shared function. pwm output mode to select this mode, bits tnm1 and tnm0 in the tmnc1 register should be set to 10 respectively and also the tnio1 and tnio0 bits should be set to 10 respectively. the pwm function within the tmn is useful for applications which require functions such as motor control, heating control, illumination control, etc. by providing a signal of fxed frequency but of varying duty cycle on the tmn output pin, a square wave ac waveform can be generated with varying equivalent dc rms values. as both the period and duty cycle of the pwm waveform can be controlled, the choice of generated waveform is extremely flexible. in the pwm mode, the tncclr bit has no effect as the pwm period. both of the ccrp and ccra registers are used to generate the pwm waveform, one register is used to clear the internal counter and thus control the pwm waveform frequency, while the other one is used to control the duty cycle. the pwm waveform frequency and duty cycle can therefore be controlled by the values in the ccra and ccrp registers. an interrupt fag, one for each of the ccra and ccrp, will be generated when a compare match occurs from either comparator a or comparator p. the tnoc bit in the tmnc1 register is used to select the required polarity of the pwm waveform while the two tnio1 and tnio0 bits are used to enable the pwm output or to force the tmn output pin to a fxed high or low level. the tnpol bit is used to reverse the polarity of the pwm output waveform. ? 10-bit ptm, pwm mode ccrp 1~1023 0 period 1~1023 1024 d?ty ccr? if f sys =16mhz, tm clock source select f sys /4, ccrp=512 and ccra=128, the tmn pwm output frequency=(f sys /4)/512=f sys /2048=7.8125 khz, duty=128/512=25%, if the duty value defned by the ccra register is equal to or greater than the period value, then the pwm output duty is 100%.
rev. 1.20 ?? ????st 2?? 201? rev. 1.20 ?9 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom co?nter val?e ccrp ccr? tnon tnp?u tnpol ccrp int. fla? tnpf ccr? int. fla? tn?f tmn o/p pin (tnoc=1) time co?nter cleared by ccrp pa?se res?me co?nter stop if tnon bit low co?nter reset when tnon ret?rns hi?h tnm [1:0] = 10 pwm d?ty cycle set by ccr? pwm res?mes operation o?tp?t controlled by other pin-shared f?nction o?tp?t inverts when tnpol = 1 pwm period set by ccrp tmn o/p pin (tnoc=0) pwm mode(n=0,1) note: 1. the counter is cleared by ccrp. 2. a counter clear sets the pwm period 3. the internal pwm function continues running even when tnio [1:0]=00 or 01 4. the tncclr bit has no i nfuence on pwm operation
rev. 1.20 ?? ????st 2?? 201? rev. 1.20 ?9 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom single pulse output mode to select this mode, bits tnm1 and tnm0 in the tmnc1 register should be set to 10 respectively and also the tnio1 and tnio0 bits should be set to 11 respectively. the single pulse output mode, as the name suggests, will generate a single shot pulse on the tmn output pin. the trigger for the pulse output leading edge is a low to high transition of the tnon bit, which can be implemented using the application program. however in the single pulse mode, the tnon bit can also be made to automatically change from low to high using the external tckn pin, which will in turn initiate the single pulse output. when the tnon bit transitions to a high level, the counter will start running and the pulse leading edge will be generated. the tnon bit should remain high when the pulse is in its active state. the generated pulse trailing edge will be generated when the tnon bit is cleared to zero, which can be implemented using the application program or when a compare match occurs from comparator a. however a compare match from comparator a will also automatically clear the tnon bit and thus generate the single pulse output trailing edge. in this way the ccra value can be used to control the pulse width. a compare match from comparator a will also generate a tmn interrupt. the counter can only be reset back to zero when the tnon bit changes from low to high when the counter restarts. in the single pulse mode ccrp is not used. the tncclr is not used in this mode. s/w command settnon or tckn pin transition ccr? trailin? ed?e s/w command clrtnon or ccr? compare match tpn o?tp?t pin p?lse width = ccr? val?e ccr? leadin? ed?e tnon bit 0 1 tnon bit 0 1 single pulse generation
rev. 1.20 ?0 ????st 2?? 201? rev. 1.20 ?1 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom co?nter val?e ccrp ccr? tnon tnp?u tnpol ccrp int. fla? tnpf ccr? int. fla? tn?f tmn o/p pin (tnoc=1) time co?nter stopped by ccr? pa?se res?me co?nter stops by software co?nter reset when tnon ret?rns hi?h tnm [1:0] = 10 ; tnio [1:0] = 11 p?lse width set by ccr? o?tp?t inverts when tnpol = 1 no ccrp interr?pts ?enerated tmn o/p pin (tnoc=0) tckn pin software tri??er cleared by ccr? match tckn pin tri??er ??to. set by tckn pin software tri??er software clear software tri??er software tri??er single pulse mode(n=0,1) note: 1. counter stopped by ccra 2. ccrp is not used 3. the pulse triggered by the tckn pin or by setting the tnon bit high 4. a tckn pin active edge will automatically set the tnon bit high. 5. in the single pulse mode, tnio [1:0] must be set to "11" and can not be changed.
rev. 1.20 ?0 ????st 2?? 201? rev. 1.20 ?1 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom capture input mode to select this mode bits tnm1 and tnm0 in the tmnc1 register should be set to 01 respectively. this mode enables external signals to capture and store the present value of the internal counter and can therefore be used for applications such as pulse width measurements. the external signal is supplied on the tpn or tckn pin, selected by the tncapts bit in the tmnc1 register. the input pin active edge can be either a rising edge, a falling edge or both rising and falling edges; the active edge transition type is selected using the tnio1 and tnio0 bits in the tmnc1 register. the counter is started when the tnon bit changes from low to high which is initiated using the application program. when the required edge transition appears on the tpn or tckn pin the present value in the counter will be latched into the ccra registers and a tmn interrupt generated. irrespective of what events occur on the tpn or tckn pin the counter will continue to free run until the tnon bit changes from high to low. when a ccrp compare match occurs the counter will reset back to zero; in this way the ccrp value can be used to control the maximum counter value. when a ccrp compare match occurs from comparator p, a tmn interrupt will also be generated. counting the number of overfow interrupt signals from the ccrp can be a useful method in measuring long pulse widths. the tnio1 and tnio0 bits can select the active trigger edge on the tpn or tckn pin to be a rising edge, falling edge or both edge types. if the tnio1 and tnio0 bits are both set high, then no capture operation will take place irrespective of what happens on the tpn or tckn pin, however it must be noted that the counter will continue to run. as the tpn or tckn pin is pin shared with other functions, care must be taken if the tmn is in the input capture mode. this is because if the pin is setup as an output, then any transitions on this pin may cause an input capture operation to be executed. the tncclr, tnoc and tnpol bits are not used in this mode.
rev. 1.20 ?2 ????st 2?? 201? rev. 1.20 ?3 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom co?nter val?e yy ccrp tnon tnp?u ccrp int. fla? tnpf ccr? int. fla? tn?f ccr? val?e time co?nter cleared by ccrp pa?se res?me co?nter reset tm capt?re pin tpn_x or tckn xx co?nter stop tnio [1:0] val?e xx yy xx yy ?ctive ed?e ?ctive ed?e ?ctive ed?e 00 C risin? ed?e 01 C fallin? ed?e 10 C both ed?es 11 C disable capt?re tnm [1:0] = 01 capture input mode (n=0,1) note: 1. tnm [1:0]=01 and active edge set by the tnio [1:0] bits 2. a tmn capture input pin active edge transfers the counter value to ccra 3. tncclr bit not used 4. no output function C tnoc and tnpol bits are not used 5. ccrp determines the counter value and the counter has a maximum count value when ccrp is equal to zero.
rev. 1.20 ?2 ????st 2?? 201? rev. 1.20 ?3 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom analog to digital converter the need to interface to real world analog signals is a common requirement for many electronic systems. however, to properly process these signals by a microcontroller, they must first be converted into digital signals by a/d converters. by integrating the a/d conversion electronic circuitry into the microcontroller , the need for external components is reduced signifcantly with the corresponding follow-on benefts of lower costs and reduced component space requirements. a/d overview the device contains a multi-channel analog to digital converter which can directly interface to external analog signals, such as that from sensors or other control signals and convert these signals directly into a 12-bit digital value. it also can convert the internal signals, such as the bandgap reference voltage, into a 12-bit digital value. the external or internal analog signal to be converted is determined by the sains2~sains0 bits together with the sacs2~sacs0 bits. note that when the external and internal analog signals are simultaneously selected to be converted, the internal analog signal will have the priority. in the meantime the external analog signal will temporarily be switched off until the internal analog signal is deselected. more detailed information about the a/d input signal is described in the "a/d converter control registers" and "a/d converter input signals" sections respectively. the accompanying block diagram shows the internal structure of the a/d converter together with its associated registers. external input channel internal analog signals a/d signal select bits ?n0~?n? v dd ? v dd /2? v dd /4? v r ? v r /2? v r /4 s?ins2~s?ins0; s?cs2~s?cs0 ?ce?~?ce0 s?cs2~s?cs0 s?ins2~s?ins0 ?/d converter st?rt ?dbz en?dc v ss ?/d clock 2 n (n=0~?) f sys s?cks2~ s?cks0 v dd en?dc s?dol s?doh ?n0 ?n1 ?n? ?/d reference volta?e ?/d data re?isters v dd v dd /2 v dd /4 v r v r /2 v r /4 ?drfs op? v ri v bg (gain=1~4) s?vrs3~s?vrs0 enop? v refo v r v dd vrefoen vrefien vref vrefo a/d converter structure
rev. 1.20 ?4 ????st 2?? 201? rev. 1.20 ?5 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom a/d converter register description overall operation of the a/d converter is controlled using six registers. a read only register pair exists to store the a/d converter data 12-bit value. one register, acerl, is used to confgure the external analog input pin function. the remaining three registers are control registers which setup the operating and control function of the a/d converter. register name bit 7 6 5 4 3 2 1 0 s? dol (?drfs=0) d3 d2 d1 d0 s? dol (?drfs=1) d? d6 d5 d4 d3 d2 d1 d0 s?doh (?drfs=0) d11 d10 d9 d? d? d6 d5 d4 s?doh (?drfs=1) d11 d10 d9 d? s?dc0 st ? rt ?dbz en?dc ?drfs s?cs2 s?cs1 s?cs0 s?dc1 s?ins2 s?ins1 s?ins0 s?cks2 s?cks1 s?cks0 s?dc2 enop ? vbgen vrefien vrefoen s? vrs3 s? vrs2 s? vrs1 s? vrs0 ?cerl ?ce? ?ce6 ?ce5 ?ce4 ?ce3 ?ce2 ?ce1 ?ce0 a/d converter registers list a/d converter data registers C sadol, sadoh as the device contains an internal 12-bit a/d converter, it requires two data registers to store the converted value. these are a high byte register, known as sadoh, and a low byte register, known as sadol. after the conversion process takes place, these registers can be directly read by the microcontroller to obtain the digitised conversion value. as only 12 bits of the 16-bit register space is utilised, the format in which the data is stored is controlled by the adrfs bit in the sadc0 register as shown in the accompanying table. d0~d11 are the a/d conversion result data bits. any unused bits will be read as zero. the a/d data registers contents will keep unchanged if the a/d converter is disabled. adrfs sadoh sadol 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 0 d11 d10 d9 d? d? d6 d5 d4 d3 d2 d1 d0 0 0 0 0 1 0 0 0 0 d11 d10 d9 d? d? d6 d5 d4 d3 d2 d1 d0 a/d converter data registers a/d converter control registers C sadc0, sadc1, sadc2, acerl to control the function and operation of the a/d converter, three control registers known as sadc0, sadc1 and sadc2 are provided. these 8-bit registers defne functions such as the selection of which analog channel is connected to the internal a/d converter, the digitised data format, the a/d clock source, the a/d reference voltage as well as controlling the start function and monitoring the a/d converter busy status. as the device contains only one actual analog to digital converter hardware circuit, each of the external and internal analog signals must be routed to the converter. the sacs2~sacs0 bits in the sadc0 register are used to determine which external channel input is selected to be converted. the sains2~sains0 bits in the sadc1 register are used to determine that the analog signal to be converted comes from the internal analog signal or external analog channel input. if the internal analog signal is selected to be converted, the external channel signal input will automatically be switched off to avoid the signal contention.
rev. 1.20 ?4 ????st 2?? 201? rev. 1.20 ?5 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom the analog input pin function selection bits in the acerl register determine which pins on i/o ports are used as external analog channels for the a/d converter input and which pins are not to be used as the a/d converter input. when the pin is selected to be an a/d input, its original function whether it is an i/o or other pin-shared functions will be removed. in addition, any internal pull- high resistor connected to the pin will be automatically removed if the pin is selected to be an a/d converter input. ? acerl register bit 7 6 5 4 3 2 1 0 name ?ce? ?ce6 ?ce5 ?ce4 ?ce3 ?ce2 ?ce1 ?ce0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 1 1 1 1 1 1 1 1 bit 7 ace7 : defne pb3 is a/d input or not 0: not a/d input 1: a/d input, an7 bit 6 ace6 : defne pa7 is a/d input or not 0: not a/d input 1: a/d input, an6 bit 5 ace5 : defne pa6 is a/d input or not 0: not a/d input 1: a/d input, an5 bit 4 ace4 : defne pa5 is a/d input or not 0: not a/d input 1: a/d input, an4 bit 3 ace3 : defne pa4 is a/d input or not 0: not a/d input 1: a/d input, an3 bit 2 ace2 : defne pb2 is a/d input or not 0: not a/d input 1: a/d input, an2 bit 1 ace1 : defne pb1 is a/d input or not 0: not a/d input 1: a/d input, an1 bit 0 ace0 : defne pb0 is a/d input or not 0: not a/d input 1: a/d input, an0 ? sadc0 register bit 7 6 5 4 3 2 1 0 name st ? rt ?dbz en?dc ?drfs s?cs2 s?cs1 s?cs0 r/w r/w r r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 bit 7 start : start the a/d conversion 0 0: start this bit is used to initiate an a/d conversion process. the bit is normally low but if set high and then cleared low again, the a/d converter will initiate a conversion process. bit 6 adbz : a/d converter busy fag 0: no a/d conversion is in progress 1: a/d conversion is in progress this read only fag is used to indicate whether the a/d conversion is in progress or not. when the start bit is set from low to high and then to low again, the adbz fag will be set to 1 to indicate that the a/d conversion is initiated. the adbz fag will be cleared to 0 after the a/d conversion is complete.
rev. 1.20 ?6 ????st 2?? 201? rev. 1.20 ?? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom bit 5 enadc : a/d converter function enable control 0: disable 1: enable this bit controls the a/d internal function. this bit should be set to one to enable the a/d converter. if the bit is set low, then the a/d converter will be switched off reducing the device power consumption. when the a/d converter function is disabled, the contents of the a/d data register pair, sadoh/sadol, will keep unchanged. bit 4 adrfs : a/d conversion data format select 0: a/d converter data format sadoh=d [11:4]; sadol=d [3:0] 1: a/d converter data format sadoh=d [11:8]; sadol=d [7:0] this bit controls the format of the 12-bit converted a/d value in the two a/d data registers. details are provided in the a/d converter data register section. bit 3 unimplemented, read as "0" bit 2~0 sacs2~sacs0 : a/d converter external analog input channel select 000: an0 001: an1 010: an2 011: an3 100: an4 101: an5 110: an6 111: an7 ? sadc1 register bit 7 6 5 4 3 2 1 0 name s?ins2 s?ins1 s?ins0 s?cks2 s?cks1 s?cks0 r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 bit 7~5 sains2~sains0 : a/d converter input signal select 000, 100: external signal C external analog channel input 001: internal signal C internal a/d converter power supply voltage v 010: internal signal C internal a/d converter power supply voltage v /2 011: internal signal C internal a/d converter power supply voltage v /4 101: internal signal C internal reference voltage v r 110: internal signal C internal reference voltage v r /2 111: internal signal C internal reference voltage v r /4 when the internal analog signal is selected to be converted, the external channel input signal will automatically be switched off regardless of the sacs2~sacs0 bit feld value. the internal reference voltage can be derived from various sources selected using the savrs3~savrs0 bits in the sadc2 register. bit 4~3 unimplemented, read as "0" bit 2~0 sacks2~sacks0 : a/d conversion clock source select 000: f 001: f /2 010: f /4 011: f /8 100: f /16 101: f /32 110: f /64 111: f /128 these bits are used to select the clock source for the a/d converter.
rev. 1.20 ?6 ????st 2?? 201? rev. 1.20 ?? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom ? sadc2 register bit 7 6 5 4 3 2 1 0 name enop ? vbgen vrefien vrefoen s? vrs3 s? vrs2 s? vrs1 s? vrs0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7 enopa : a/d converter opa function enable control 0: disable 1: enable this bit controls the internal opa function to provide various reference voltage for the a/d converter. when the bit is set high, the internal reference voltage, v r , can be used as the internal converted signal or reference voltage by the a/d converter. if the internal reference voltage is not used by the a/d converter, then the opa function should be properly confgured to conserve power. bit 6 vbgen : internal bandgap reference voltage enable control 0: disable 1: enable this bit controls the internal bandgap circuit on/off function to the a/d converter. when the bit is set high, the bandgap reference voltage can be used by the a/d converter. if the bandgap reference voltage is not used by the a/d converter and the lvd or lvr function is disabled, then the bandgap reference circuit will be automatically switched off to conserve power. when the bandgap reference voltage is switched on for use by the a/d converter, a time, t bgs , should be allowed for the bandgap circuit to stabilise before implementing an a/d conversion. bit 5 vrefien : vref pin selection bit 0: disable C vref pin is not selected 1: enable C vref pin is selected bit 4 vrefoen : vrefo pin selection bit 0: disable C vrefo pin is not selected 1: enable C vrefo pin is selected bit 3~0 savrs3~savrs0 : a/d converter reference voltage select 0000: v 0001: v ref 0010: v ref 2 0011: v ref 3 0100: v ref 4 1001: reserved, can not be used 1010: v bg 2 1011: v bg 3 1100: v bg 4 others: v when the a/d converter reference voltage source is selected to derive from the internal v bg voltage, the reference voltage which comes from the external vdd or vref pin will be automatically switched off.
rev. 1.20 ?? ????st 2?? 201? rev. 1.20 ?9 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom a/d converter input signals all of the a/d analog input pins are pin-shared with the i/o pins as well as other functions. the corresponding selectio n bits in the acerl register determine which external input pins are selected as a/d converter analog channel inputs or othe r functional pins. if the corresponding pin is setup to be an a/d converter analog channel input, the original pin functions will be disabled. in this way, pins can be changed under program control to change their function between a/d inputs and other functions. all pull-high resistors, which are setup through register programming, will be automatically disconnected if the pins are setup as a/d inputs. note that it is not necessary to frst setup the a/d pin as an input in the port control register to enable the a/d input as when the relevant a/d input function selection bits enable an a/d input, the status of the port control register will be overridden. after the desired external pins are selected as the a/d analog channel inputs using the corresponding acen bits in the acerl register, the analog signal to be converted can come from these external channel inputs. if the sains2~sains0 bits are set to "000" or "100", the external analog channel input will be selected to be converted and the sacs2~sacs0 bits can deternine which external channel is selected to be converted. if the sains2~sains0 bits are set to any other values except "000" and "100", one of the internal analog signals can be selected to be converted. the internal analog signals can be derived from the a/d converter supply power, v dd , or internal reference voltage, v r , with a specifc ratio of 1, 1/2 or 1/4. note that if the internal analog signal is selected to be converted, the external channel signal input will automatically be switched off to avoid the signal contention. sains [2:0] sacs [2:0] input signals description 000? 100 000~111 ?n0~?n? external channel analo? inp?t 001 xxx v dd ?/d converter power s?pply volta?e 010 xxx v dd /2 ?/d converter power s?pply volta?e/2 011 xxx v dd /4 ?/d converter power s?pply volta?e/4 101 xxx v r internal reference volta?e 110 xxx v r /2 internal reference volta?e/2 111 xxx v r /4 internal reference volta?e/4 a/d converter input signal selection a/d converter reference voltage the actual reference voltage, v ref , supplied to the a/d converter can be derived from the positive power supply pin, v dd , an external reference source supplied on pin vref or an internal reference source derived from the bandgap circuit, a choice which is made through the savrs3~savrs0 bits in the sadc2 register. then the actual selected reference voltage source can be amplifed through a programmable gain amplifer except the voltage sourced from v dd . the opa gain can be equal to 1, 2, 3 or 4. note that the desired reference voltage selected using the savrs feld will be output on the vrefo pin. as the vref and vrefo pins both are pin-shared with other functions, when the vref or vrefo pin is selected as the reference voltage pin, the vref or vrefo selection bit, vrefien or vrefoen, should be properly confgured to disable other pin-shared functions before the reference voltage pin function is used. note that the analog input values must not be allowed to exceed the value of the reference voltage for the a/d converter.
rev. 1.20 ?? ????st 2?? 201? rev. 1.20 ?9 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom a/d operation the start bit in the sadc0 register is used to start the ad conversion. when the microcontroller sets this bit from low to high and then low again, an analog to digital conversion cycle will be initiated. the adbz bit in the sadc0 register is used to indicate whether the analog to digital conversion process is in progress or not. this bit will be automatically set to 1 by the microcontroller after an a/d conversion is successfully initiated. when the a/d conversion is complete, the adbz will be cleared to 0. in addition, the corresponding a/d interrupt request fag will be set in the interrupt control register, and if the corresponding interrupt control bits are enabled, an internal interrupt signal will be generated. this a/d internal interrupt signal will direct the program flow to the associated a/d internal interrupt address for processing. if the a/d internal interrupt is disabled, the microcontroller can poll the adbz bit in the sadc0 register to check whether it has been cleared as an alternative method of detecting the end of an a/d conversion cycle. the clock source for the a/d converter, which originates from the system clock f sys , can be chosen to be either f sys or a subdivided version of f sys . the division ratio value is determined by the sacks2~sacks0 bits in the sadc1 register. although the a/d clock source is determined by the system clock f sys and by bits sacks2~sacks0, there are some limitations on the maximum a/d clock source speed that can be selected. as the recommended range of permissible a/d clock period, t adck , is from 0.5s to 10s, care must be taken for system clock frequencies. for example, as the system clock operates at a frequency of 8mhz, the sacks2~sacks0 bits should not be set to 000, 001 or 111. doing so will give a/d clock periods that are less than the minimum a/d clock period which may result in inaccurate a/d conversion values. refer to the following table for examples, where values marked with an asterisk * show where, depending upon the device, special care must be taken, as the values may be less than the specifed minimum a/d clock period. f sys a/d clock period (t adck ) sacks [2:0]=000 (f sys ) sacks [2:0]=001 (f sys /2) sacks [2:0]=010 (f sys /4) sacks [2:0]=011 (f sys /8) sacks [2:0]=100 (f sys /16) sacks [2:0]=101 (f sys /32) sacks [2:0]=110 (f sys /64) sacks [2:0]=111 (f sys /128) 1mhz 1s 2s 4s 8s 16s* 32s* 64s* 12? s* 2mhz 500ns 1s 2s 4s 8s 16s* 32s* 64s* 4mhz 250ns* 500ns 1s 2s 4s 8s 16s* 32s* ?mhz 125ns* 250ns* 500ns 1s 2s 4s 8s 16s* 12mhz ?3ns* 16?ns* 333ns* 66?ns 1.33s 2.67s 5.33s 10.6? s* 16mhz 62.5ns* 125ns* 250ns* 500ns 1s 2 s 4 s ? s a/d clock period examples controlling the power on/off function of the a/d converter circuitry is implemented using the enadc bit in the sadc0 register. this bit must be set high to power on the a/d converter. when the enadc bit is set high to power on the a/d converter internal circuitry, a certain delay, as indicated in the timing diagram, must be allowed before an a/d conversion is initiated. even if no pins are selected for use as a/d inputs, if the enadc bit is high, then some power will still be consumed. in power conscious applications it is therefore recommended that the enadc is set low to reduce power consumption when the a/d converter function is not being us ed.
rev. 1.20 90 ????st 2?? 201? rev. 1.20 91 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom c onversion rate and timing diagram a complete a/d conversion contains two parts, data sampling and data conversion. the data sampling which is defned as t ads takes 4 a/d clock cycles and the data conversion takes 12 a/d clock cycles. therefore a total of 16 a/d clock cycles for an a/d conversion which is defned as t adc are necessary. maximum single a/d conversion rate=a/d clock period / 16 (1) the accompanying diagram shows graphically the various stages involved in an analog to digital conversion process and its associated timing. after an a/d conversion process has been initiated by the application program, the microcontroller internal hardware will begin to carry out the conversion, during which time the program can continue with other functions. the time taken for the a/d conversion is 16 t adck clock cycles where t adck is equal to the a/d clock period. en?dc st?rt ?dbz s?cs[2:0] off on off on t on2st t ?ds ?/d samplin? time t ?ds ?/d samplin? time start of ?/d conversion start of ?/d conversion start of ?/d conversion end of ?/d conversion end of ?/d conversion t ?dc ?/d conversion time t ?dc ?/d conversion time t ?dc ?/d conversion time 011b 010b 000b 001b ?/d channel switch (s?ins =000b) a/d conversion example timing diagram
rev. 1.20 90 ????st 2?? 201? rev. 1.20 91 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom summary of a/d conversion steps the following summarises the individual steps that should be executed in order to implement an a/d conversion process. ? step 1 select the required a/d conversion clock by properly programming the sacks2~sacks0 bits in the sadc1 register. ? step 2 enable the a/d converter by setting the enadc bit in the sadc0 register to one. ? step 3 select which signal is to be connected to the internal a/d converter by correctly confguring the sains and sacs bit felds select the external channel input to be converted, go to step 4. select the internal analog signal to be converted, go to step 5. ? step 4 if the a/d input signal comes from the external channel input selecting by confguring the sains bit feld, the corresponding pins should frst be confgured as a/d input function by confguring the relevant pin-shared function control bits. the desired analog channel then should be selected by confguring the sacs bit feld. after this step, go to step 6. ? step 5 if the a/d input signal is selected to come from the internal analog signal, the sains bit field should be properly configured and then the external channel input will automatically be disconnected regardless of the sacs bit feld value. after this step, go to step 6. ? step 6 select the reference voltgage source by confguring the savrs3~savrs0 bits. ? step 7 select the a/d converter output data format by confguring the adrfs bit. ? step 8 if a/d conversion interrupt is used, the interrupt control registers must be correctly confgured to ensure the a/d interrupt function is active. the master interrupt bontrol bit, emi, and the a/d conversion interrupt control bit, ade, must both be set high in advance. ? step 9 the a/d conversion procedure can now be initialized by setting the start bit from low to high and then low again. ? step 10 if a/d conversion is in progress, the adbz flag will be set high. after the a/d conversion process is complete, the adbz flag will go low and then the output data can be read from sadoh and sadol registers. note: when checking for the end of the conversion process, if the method of polling the adbz bit in the sadc0 register is used, the interrupt enable step above can be omitted.
rev. 1.20 92 ????st 2?? 201? rev. 1.20 93 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom programming considerations during microcontroller operations where the a/d converter is not being used, the a/d internal circuitry can be switched off to reduce power consumption, by setting bit enadc low in the sadc0 register. when this happens, the internal a/d converter circuits will not consume power irrespective of what analog voltage is applied to their input lines. if the a/d converter input lines are used as normal i/os, then care must be taken as if the input voltage is not at a valid logic level, then this may lead to some increase in power consumption. a/d transfer function as the device contains a 12-bit a/d converter, its full-scale converted digitised value is equal to fffh. since the full-scale analog input value is equal to the actual a/d converter reference voltage, v ref , this gives a single bit analog input value of v ref divided by 4096. 1 lsb=v ref 4096 the a/d converter input voltage value can be calculated using the following equation: a/d input voltage=a/d output digital value v ref 4096 the diagram shows the ideal transfer function between the analog input value and the digitised output value for the a/d converter. except for the digitised zero value, the subsequent digitised values will change at a point 0.5 lsb below where they would change without the offset, and the last full scale digitised value will change at a point 1.5 lsb below the v ref level. note that here the v ref voltage is the actual a/d converter reference voltage determined by the savrs feld. fffh ffeh ffdh 03h 02h 01h 0 1 2 3 4093 4094 4095 4096 v ref 4096 analog input voltage a/d conversion result 1.5 lsb 0.5 lsb ideal a/d transfer function
rev. 1.20 92 ????st 2?? 201? rev. 1.20 93 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom a/d programming examples the following two programming examples illustrate how to setup and implement an a/d conversion. in the frst example, the method of polling the adbz bit in the sadc0 register is used to detect when the conversion cycle is complete, whereas in the second example, the a/d interrupt is used to determine when the conversion is complete. example: using an adbz polling method to detect the end of conversion clr ade ; disable adc interrupt mov a,03h mov sadc1,a ; select f sys /8 as a/d clock set enadc ; enable a/d converter mov a,03h ; setup acerl to confgure pin an1 and an0 mov acerl,a mov a,20h mov sadc0,a ; enable and connect an0 channel to a/d converter mov a,00h ; select v dd as reference voltage and mov sadc2,a ; switch off opa and bandgap reference voltage : start_conversion: clr start ; high pulse on start bit to initiate conversion set start ; reset a/d clr start ; start a/d : polling_eoc: sz adbz ; poll the sadc0 register adbz bit to detect end of a/d conversion jmp polling_eoc ; continue polling : mov a,sadol ; read low byte conversion result value mov sadol_buffer,a ; save result to user defned register mov a,sadoh ; read high byte conversion result value mov sadoh_buffer,a ; save result to user defned register : jmp start_conversion ; start next a/d conversion
rev. 1.20 94 ????st 2?? 201? rev. 1.20 95 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom example: using the interrupt method to detect the end of conversion clr ade ; disable adc interrupt mov a,03h mov sadc1,a ; select f sys /8 as a/d clock set enadc ; enable a/d converter mov a,03h ; setup acerl to confgure pin an1 and an0 mov acerl,a mov a,20h mov sadc0,a ; enable and connect an0 channel to a/d converter mov a,00h ; select v dd as reference voltage and mov sadc2,a ; switch off opa and bandgap reference voltage : start_conversion: clr start ; high pulse on start bit to initiate conversion set start ; reset a/d clr start ; start a/d clr adf ; clear adc interrupt request fag set ade ; enable adc interrupt set emi ; enable global interrupt : : adc_isr: ; adc interrupt service routine mov acc_stack,a ; save acc to user defned memory mov a,status mov status_stack,a ; save status to user defned memory : mov a, sadol ; read low byte conversion result value mov sadol_buffer,a ; save result to user defned register mov a, sadoh ; read high byte conversion result value mov sadoh_buffer,a ; save result to user defned register : exit_int_isr: mov a,status_stack mov status,a ; restore status from user defned memory mov a,acc_stack ; restore acc from user defned memory reti
rev. 1.20 94 ????st 2?? 201? rev. 1.20 95 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom serial interface module C sim the device contains a serial interface module, which includes both the four-line spi interface or two-line i 2 c interface types, to allow an easy method of communication with external peripheral hardware. having relatively simple communication protocols, these serial interface types allow the microcontroller to interface to external spi or i 2 c based hardware such as sensors, flash or eeprom memory, etc. the sim interface pins are pin-shared with other i/o pins and therefore the sim interface functional pins must frst be selected using the corresponding pin-remapping function selection bits. as both interface types share the same pins and registers, the choice of whether the spi or i 2 c type is used is made using the sim operating mode control bits, named sim2~sim0, in the simc0 register. these pull-high resistors of the sim pin-shared i/o pins are selected using pull- high control registers when the sim function is enabled and the corresponding pins are used as sim input pins. spi interface the spi interface is often used to communicate with external peripheral devices such as sensors, flash or eeprom memory devices, etc. originally developed by motorola, the four line spi interface is a synchronous serial data interface that has a relatively simple communication protocol simplifying the programming requirements when communicating with external hardware devices. the communication is full duplex and operates as a slave/master type, where the device can be either master or slave. although the spi interface specifcation can control multiple slave devices from a single master, the device provides only one scs pin. if the master needs to control multiple slave devices from a single master, the master can use i/o pin to select the slave devices. spi interface operation the spi interface is a full duplex synchronous serial data link. it is a four line interface with pin names sdi, sdo, sck and scs . pins sdi and sdo are the serial data input and serial data output lines, sck is the serial clock line and scs is the slave select line. as the spi interface pins are pin-shared with normal i/o pins and with the i 2 c function pins, the spi interface pins must frst be selected by confguring the pin-remapping function selection bits and setting the correct bits in the simc0 and simc2 registers. after the desired spi confguration has been set it can be disabled or enabled using the simen bit in the simc0 register. communication between devices connected to the spi interface is carried out in a slave/master mode with all data transfer initiations being implemented by the master. the master also controls the clock signal. as the device only contains a single scs pin only one slave device can be utilized. the scs pin is controlled by software, set csen bit to 1 to enable scs pin function, set csen bit to 0 the scs pin will be foating state. the spi function in this device offers the following features: ? full duplex synchronous data transf er ? both master and slave modes ? lsb frst or msb frst data transmission modes ? transmission complete fag ? rising or falling active clock edge the status of the spi interface pins is determined by a number of factors such as whether the device is in the master or slave mode and upon the condition of certain control bits such as csen and simen.
rev. 1.20 96 ????st 2?? 201? rev. 1.20 9? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom sck spi master sdo sdi scs sck spi slave sdi sdo scs spi master/slave connection simd tx/rx shift re?ister sdi pin clock ed?e/polarity control ckeg ckpolb clock so?rce select f sys f tbc tm1 ccrp matc h freq?ency/2 sck pin csen b?sy stat?s sdo pin scs pin data b?s wcol trf simicf spi block diagram spi registers there are three internal registers which control the overall operation of the spi interface. these are the simd data register and two registers simc0 and simc2. note that the simc1 register is only used by the i 2 c interface. register name bit 7 6 5 4 3 2 1 0 simc0 sim2 sim1 sim0 simdbnc1 simdbnc0 simen simicf simc2 d? d6 ckpolb ckeg mls csen wcol trf simd d? d6 d5 d4 d3 d2 d1 d0 spi registers list ? simd register the simd register is used to store the data being transmitted and received. the same register is used by both the spi and i 2 c functions. before the device writes data to the spi bus, the actual data to be transmitted must be placed in the simd register. after the data is received from the spi bus, the device can read it from the simd register. any transmission or reception of data from the spi bus must be made via the simd register. bit 7 6 5 4 3 2 1 0 name d? d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por x x x x x x x x "x": ?nknown
rev. 1.20 96 ????st 2?? 201? rev. 1.20 9? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom there are also two control registers for the spi interface, simc0 and simc2. note that the simc2 register also has the name sima which is used by the i 2 c function. the simc1 register is not used by the spi function, only by the i 2 c function. register simc0 is used to control the enable/disable function and to set the data transmission clock frequency. register simc2 is used for other control functions such as lsb/msb selection, write collision fag, etc. ? simc0 register bit 7 6 5 4 3 2 1 0 name sim2 sim1 sim0 simdbnc1 simdbnc0 simen simicf r/w r/w r/w r/w r/w r/w r/w r/w por 1 1 1 0 0 0 0 bit 7~5 sim2~sim0 : sim operating mode control 000: spi master mode; spi clock is f /4 001: spi master mode; spi clock is f /16 010: spi master mode; spi clock is f /64 011: spi master mode; spi clock is f tbc 100: spi master mode; spi clock is tm1 ccrp match frequency/2 101: spi slave mode 110: i 2 c slave mode 111: non sim function these bits setup the overall operating mode of the sim function. as well as selecting if the i 2 c or spi function, they are used to control the spi master/slave selection and the spi master clock frequency. the spi clock is a function of the system clock but can also be chosen to be sourced from tm1 or f tbc . if the spi slave mode is selected then the clock will be supplied by an external master device. bit 4 unimplemented, read as "0" bit 3~2 simdbnc1~simdbnc0 : i 2 c debounce time selection 00: no debounce 01: 2 system clock debounce 1x: 4 system clock debounce bit 1 simen : sim enable control 0: disable 1: enable the bit is the overall on/off control for the sim interface. when the simen bit is cleared to zero to disable the sim interface, the sdi, sdo, sck and scs , or sda and scl lines will lose their spi or i 2 c function and the sim operating current will be reduced to a minimum value. when the bit is high the sim interface is enabled. the sim confguration option must have frst enabled the sim interface for this bit to be effective.if the sim is confgured to operate as an spi interface via the sim2~sim0 bits, the contents of the spi control registers will remain at the previous settings when the simen bit changes from low to high and should therefore be frst initialised by the application program. if the sim is confgured to operate as an i 2 c interface via the sim2~sim0 bits and the simen bit changes from low to high, the contents of the i 2 c control bits such as htx and txak will remain at the previous settings and should therefore be first initialised by the application program while the relevant i 2 c flags such as hcf, haas, hbb, srw and rxak will be set to their default states. bit 0 simicf : sim incomplete flag 0: sim incomplete condition not occurred 1: sim incomplete condition occured this bit is only available when the sim is confgured to operate in an spi slave mode. if the spi operates in the slave mode with the simen and csen bits both being set to 1 but the scs line is pulled high by the external master device before the spi data transfer is completely fnished, the simicf bit will be set to 1 together with the trf bit. when this condition occurs, the corresponding interrupt will occur if the interrupt function is enabled. however, the trf bit will not be set to 1 if the simicf bit is set to 1 by software application program.
rev. 1.20 9? ????st 2?? 201? rev. 1.20 99 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom ? simc2 register bit 7 6 5 4 3 2 1 0 name d? d6 ckpolb ckeg mls csen wcol trf r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~6 undefned bits these bits can be read or written by the application program. bit 5 ckpolb : spi clock line base condition selection 0: the sck line will be high when the clock is inactive. 1: the sck line will be low when the clock is inactive. the ckpolb bit determines the base condition of the clock line, if the bit is high, then the sck line will be low when the clock is inactive. when the ckpolb bit is low, then the sck line will be high when the clock is inactive. bit 4 ckeg : spi sck clock active edge type selection ckpolb=0 0: sck is high base level and data capture at sck rising edge 1: sck is high base level and data capture at sck falling edge ckpolb=1 0: sck is low base level and data capture at sck falling edge 1: sck is low base level and data capture at sck rising edge the ckeg and ckpolb bits are used to setup the way that the clock signal outputs and inputs data on the spi bus. these two bits must be confgured before data transfer is executed otherwise an erroneous clock edge may be generated. the ckpolb bit determines the base condition of the clock line, if the bit is high, then the sck line will be low when the clock is inactive. when the ckpolb bit is low, then the sck line will be high when the clock is inactive. the ckeg bit determines active clock edge type which depends upon the condition of ckpolb bit. bit 3 mls : spi data shift order 0: lsb frst 1: msb frst this is the data shift select bit and is used to select how the data is transferred, either msb or lsb frst. setting the bit high will select msb frst and low for lsb frst. bit 2 csen : spi scs pin control 0: disable 1: enable the csen bit is used as an enable/disable for the scs pin. if this bit is low, then the scs pin will be disabled and placed into i/o pin or other pin-shared functions. if the bit is high, the scs pin will be enabled and used as a select pin. bit 1 wcol : spi write collision fag 0: no collision 1: collision the wcol fag is used to detect whether a data collision has occurred or not. if this bit is high, it means that data has been attempted to be written to the simd register duting a data transfer operation. this writing operation will be ignored if data is being transferred. this bit can be cleared by the application program. bit 0 trf : spi transmit/receive complete fag 0: spi data is being transferred 1: spi data transfer is completed the trf bit is the transmit/receive complete fag and is set to 1 automatically when an spi data transfer is completed, but must cleared to 0 by the application program. it can be used to generate an interrupt.
rev. 1.20 9? ????st 2?? 201? rev. 1.20 99 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom spi communication after the spi interface is enabled by setting the simen bit high, then in the master mode, when data is written to the simd register, transmission/reception will begin simultaneously. when the data transfer is complete, the trf flag will be set automatically, but must be cleared using the application program. in the slave mode, when the clock signal from the master has been received, any data in the simd register will be transmitted and any data on the sdi pin will be shifted into the simd register. the master should output a scs signal to enable the slave devices before a clock signal is provided. the slave data to be transferred should be well prepared at the appropriate moment relative to the scs signal depending upon the confgurations of the ckpolb bit and ckeg bit. the accompanying timing diagram shows the relationship between the slave data and scs signal for various confgurations of the ckpolb and ckeg bits. the spi master mode will continue to function even in the idle mode if the selected spi clock source is running. sck (ckpolb=1? ckeg=0) sck (ckpolb=0? ckeg=0) sck (ckpolb=1? ckeg=1) sck (ckpolb=0? ckeg=1) scs sdo (ckeg=0) sdo (ckeg=1) sdi data capt?re write to simd simen? csen=1 simen=1? csen=0 (external p?ll-hi?h) d?/d0 d6/d1 d5/d2 d4/d3 d3/d4 d2/d5 d1/d6 d0/d? d?/d0 d6/d1 d5/d2 d4/d3 d3/d4 d2/d5 d1/d6 d0/d? spi master mode timing sck (ckpolb=1) sck (ckpolb=0) scs sdo sdi data capt?re write to simd (sdo does not chan?e ?ntil first sck ed?e) d?/d0 d6/d1 d5/d2 d4/d3 d3/d4 d2/d5 d1/d6 d0/d? spi slave mode timing C ckeg=0
rev. 1.20 100 ????st 2?? 201? rev. 1.20 101 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom sck (ckpolb=1) sck (ckpolb=0) scs sdo sdi data capt?re d?/d0 d6/d1 d5/d2 d4/d3 d3/d4 d2/d5 d1/d6 d0/d? write to simd (sdo chan?es as soon as writin? o cc?rs; sdo is floatin? if scs=1) note: for spi slave mode? if simen= 1 and csen=0? spi is always enabled and i?nores the scs level. spi slave mode timing C ckeg=1 clear wcol write data into simd wcol=1? transmission completed? (trf=1?) read data from simd clear trf end transfer finished? ? spi transfer master or slave ? simen=1 confi??re ckpolb? ckeg? csen and mls ? sim[2:0]=000? 001? 010? 011 or 100 sim[2:0]=101 master slave y y n n n y spi transfer control flow chart
rev. 1.20 100 ????st 2?? 201? rev. 1.20 101 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom i 2 c interface the i 2 c interface is used to communicate with external peripheral devices such as sensors, eeprom memory etc. originally developed by philips, it is a two line low speed serial interface for synchronous serial data transfer. the advantage of only two lines for communication, relatively simple communication protocol and the ability to accommodate multiple devices on the same bus has made it an extremely popular interface type for many applications. device slave device master device slave vdd sd? scl i 2 c master slave bus connection i 2 c interface operation the i 2 c serial interface is a two line interface, a serial data line, sda, and serial clock line, scl. as many devices may be connected together on the same bus, their outputs are both open drain types. for this reason it is necessary that external pull-high resistors are connected to these outputs. note that no chip select line exists, as each device on the i 2 c bus is identifed by a unique address which will be transmitted and received on the i 2 c bus. when two devices communicate with each other on the bidirectional i 2 c bus, one is known as the master device and one as the slave device. both master and slave can transmit and receive data, however, it is the master device that has overall control of the bus. for the device, which only operates in slave mode, there are two methods of transferring data on the i 2 c bus, the slave transmit mode and the slave receive mode. shift re?ister transmit/ receive control unit f sys f sub data b?s i 2 c ?ddress re?ister (sim?) i 2 c data re?ister (simd) ?ddress comparator read/write slave srw detect start or stop hbb time-o?t control simtof ?ddress match C h??s i 2 c interr?pt debo?nce circ?itry scl pin m u x tx?k data o?t msb simtoen ?ddress match simdbnc[1:0] sd? pin data in msb direction control htx ?-bit data transfer complete C hcf i 2 c block diagram
rev. 1.20 102 ????st 2?? 201? rev. 1.20 103 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom st?rt si?nal from master send slave address and r/w bit from master ?cknowled?e from slave send data byte from master ?cknowled?e from slave stop si?nal from master the simdbnc1 and simdbnc0 bits determine the debounce time of the i 2 c interface. this uses the system clock to in effect add a debounce time to the external clock to reduce the possibility of glitches on the clock line causing erroneous operation. the debounce time, if selected, can be chosen to be either 2 or 4 system cl ocks. to achieve the required i 2 c data transfer speed, there exists a relationship between the system clock, f sys , and the i 2 c debounce time. for either the i 2 c standard or fast mode operation, users must take care of the selected system clock frequency and the confgured debounce time to match the criterion shown in the following table. i 2 c debounce time selection i 2 c standard mode (100khz) i 2 c fast mode (400khz) no devo?nce f sys > 2 mhz f sys > 5 mhz 2 system clock debo?nce f sys > 4 mhz f sys > 10 mhz 4 system clock debo?nce f sys > ? mhz f sys > 20 mhz i 2 c minimum f sys frequency i 2 c registers there are three control registers associated with the i 2 c bus, simc0, simc1 and simtoc, one slave address register, sima, and one data register, simd. the simd register, which is shown in the above spi section, is used to store the data being transmitted and received on the i 2 c bus. before the microcontroller writes data to the i 2 c bus, the actual data to be transmitted must be placed in the simd register. after the data is received from the i 2 c bus, the microcontroller can read it from the simd register. any transmission or reception of data from the i 2 c bus must be made via the simd register. note that the sima register also has the name simc2 which is used by the spi function. bit simen and bits sim2~sim0 in register simc0 are used by the i 2 c interface. register name bit 7 6 5 4 3 2 1 0 simc0 sim2 sim1 sim0 simdbnc1 simdbnc0 simen simicf simc1 hcf h??s hbb htx tx?k srw i?mwu rx?k sim? ?6 ?5 ?4 ?3 ?2 ?1 ?0 d0 simd d? d6 d5 d4 d3 d2 d1 d0 simtoc simtoen simtof simtos5 simtos4 simtos3 simtos2 simtos1 simtos0 i 2 c registers list
rev. 1.20 102 ????st 2?? 201? rev. 1.20 103 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom ? simd register the simd register is used to store the data being transmitted and received. the same register is used by both the spi and i 2 c functions. before the device writes data to the i 2 c bus, the actual data to be transmitted must be placed in the simd register. after the data is received from the i 2 c bus, the device can read it from the simd register. any transmission or reception of data from the i 2 c bus must be made via the simd register. bit 7 6 5 4 3 2 1 0 name d? d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por x x x x x x x x "x": ?nknown ? sima register the sima register is also used by the spi interface but has the name simc2. the sima register is the location where the 7-bit slave address of the slave device is stored. bits 7~1 of the sima register defne the device slave address. bit 0 is not defned. when a master device, which is connected to the i 2 c bus, sends out an address, which matches the slave address in the sima register, the slave device will be selected. note that the sima register is the same register address as simc2 which is used by the spi interface. bit 7 6 5 4 3 2 1 0 name ?6 ?5 ?4 ?3 ?2 ?1 ?0 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por x x x x x x x x "x": ?nknown bit 7~1 a6~a0 : i 2 c slave address a6~a0 is the i 2 c slave address bit 6 ~ bit 0 bit 0 undefned bit the bit can be read or written by the application program. there are also three control registers for the i 2 c interface, simc0, simc1 and simtoc. the register simc0 is used to control the enable/disable function and to set the data transmission clock frequency.the sim c1 register contains the relevant fags which are used to indicate the i 2 c communication status. the simtoc register is used to control the i 2 c bus time-out function which is described in the i 2 c time-out control section.
rev. 1.20 104 ????st 2?? 201? rev. 1.20 105 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom ? simc0 register bit 7 6 5 4 3 2 1 0 name sim2 sim1 sim0 simdbnc1 simdbnc0 simen simicf r/w r/w r/w r/w r/w r/w r/w r/w por 1 1 1 0 0 0 0 bit 7~5 sim2~sim0 : sim operating mode control 000: spi master mode; spi clock is f /4 001: spi master mode; spi clock is f /16 010: spi master mode; spi clock is f /64 011: spi master mode; spi clock is f tbc 100: spi master mode; spi clock is tm1 ccrp match frequency/2 101: spi slave mode 110: i 2 c slave mode 111: non sim function these bits setup the overall operating mode of the sim function. as well as selecting if the i 2 c or spi function, they are used to control the spi master/slave selection and the spi master clock frequency. the spi clock is a function of the system clock but can also be chosen to be sourced from tm1 or f tbc . if the spi slave mode is selected then the clock will be supplied by an external master device. bit 4 unimplemented, read as "0" bit 3~2 simdbnc1~ simdbnc0 : i 2 c debounce time selection 00: no debounce 01: 2 system clock debounce 1x: 4 system clock debounce bit 1 simen : sim enable control 0: disable 1: enable the bit is the overall on/off control for the sim interface. when the simen bit is cleared to zero to disable the sim interface, the sdi, sdo, sck and scs , or sda and scl lines will lose their spi or i 2 c function and the sim operating current will be reduced to a minimum value. when the bit is high the sim interface is enabled. the sim confguration option must have frst enabled the sim interface for this bit to be effective.if the sim is confgured to operate as an spi interface via the sim2~sim0 bits, the contents of the spi control registers will remain at the previous settings when the simen bit changes from low to high and should therefore be frst initialised by the application program. if the sim is confgured to operate as an i 2 c interface via the sim2~sim0 bits and the simen bit changes from low to high, the contents of the i 2 c control bits such as htx and txak will remain at the previous settings and should therefore be first initialised by the application program while the relevant i 2 c flags such as hcf, haas, hbb, srw and rxak will be set to their default states. bit 0 simicf : sim incomplete flag 0: sim incomplete condition not occurred 1: sim incomplete condition occured this bit is only available when the sim is confgured to operate in an spi slave mode. if the spi operates in the slave mode with the simen and csen bits both being set to 1 but the scs line is pulled high by the external master device before the spi data transfer is completely fnished, the simicf bit will be set to 1 together with the trf bit. when this condition occurs, the corresponding interrupt will occur if the interrupt function is enabled. however, the trf bit will not be set to 1 if the simicf bit is set to 1 by software application program.
rev. 1.20 104 ????st 2?? 201? rev. 1.20 105 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom ? simc1 register bit 7 6 5 4 3 2 1 0 name hcf h??s hbb htx tx?k srw i?mwu rx?k r/w r r r r/w r/w r/w r/w r por 1 0 0 0 0 0 0 1 bit 7 hcf : i 2 c bus data transfer completion fag 0: data is being transferred 1: completion of an 8-bit data transfer the hcf flag is the data transfer flag. this flag will be zero when data is being transferred. upon completion of an 8-bit data transfer the flag will go high and an interrupt will be generated. bit 6 haas : i 2 c bus data transfer completion fag 0: not address match 1: address match the haas fag is the address match fag. this fag is used to determine if the slave device address is the same as the master transmit address. if the addresses match then this bit will be high, if there is no match then the fag will be low. bit 5 hbb : i 2 c bus busy fag 0: i 2 c bus is not busy 1: i 2 c bus is busy the hbb fag is the i 2 c busy fag. this fag will be "1" when the i 2 c bus is busy which will occur when a start signal is detected. the fag will be set to "0" when the bus is free which will occur when a stop signal is detected. bit 4 htx : i 2 c slave device transmitter/receiver selection 0: slave device is the receiver 1: slave device is the transmitter bit 3 txak : i 2 c bus transmit acknowledge fag 0: slave send acknowledge fag 1: slave does not send acknowledge fag the txak bit is the transmit acknowledge fag. after the slave device receipt of 8-bits of data, this bit will be transmitted to the bus on the 9 th clock from the slave device. the slave device must always set txak bit to "0" before further data is received. bit 2 srw : i 2 c slave read/write fag 0: slave device should be in receive mode 1: slave device should be in transmit mode the srw flag is the i 2 c slave read/write flag. this flag determines whether the master device wishes to transmit or receive data from the i 2 c bus. when the transmitted address and slave address is match, that is when the haas fag is set high, the slave device will check the srw fag to determine whether it should be in transmit mode or receive mode. if the srw fag is high, the master is requesting to read data from the bus, so the slave device should be in transmit mode. when the srw flag is zero, the master will write data to the bus, therefore the slave device should be in receive mode to read this data. bit 1 iamwu : i 2 c address match wake-up control 0: disable 1: enable C must be cleared by the application program after wake-up this bit should be set to 1 to enable the i 2 c address match wake up from the sleep or idle mode. if the iamwu bit has been set before entering either the sleep or idle mode to enable the i 2 c address match wake up, then this bit must be cleared by the application program after wake-up to ensure correction device operation.
rev. 1.20 106 ????st 2?? 201? rev. 1.20 10? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom bit 0 rxak : i 2 c bus receive acknowledge fag 0: slave receives acknowledge fag 1: slave does not receive acknowledge fag the rxak flag is the receiver acknowledge flag. when the rxak flag is "0", it means that a acknowledge signal has been received at the 9 th clock, after 8 bits of data have been transmitted. when the slave device in the transmit mode, the slave device checks the rxak fag to determine if the master receiver wishes to receive the next byte. the slave transmitter will therefore continue sending out data until the rxak fag is "1". when this occurs, the sl ave transmitter will release the sda line to allow the master to send a stop signal to release the i 2 c bus. communication on the i 2 c bus requires four separate steps, a start signal, a slave device address transmission, a data transmission and finally a stop signal. when a start signal is placed on the i 2 c bus, all devices on the bus will receive this signal and be notifed of the imminent arrival of data on the bus. the frst seven bits of the data will be the slave address with the frst bit being the msb. if the address of the slave device matches that of the transmitted address, the haas bit in the simc1 register will be set and an i 2 c interrupt will be generated. after entering the interrupt service routine, the slave device must frst check the condition of the haas and simtof bits to determine whether the interrupt source originates from an address match, 8-bit data transfer completion or i 2 c bus time-out occurrence. during a data transfer, note that after the 7-bit slave address has been transmitted, the following bit, which is the 8 th bit, is the read/write bit whose value will be placed in the srw bit. this bit will be checked by the slave device to determine whether to go into transmit or receive mode. before any transfer of data to or from the i 2 c bus, the microcontroller must initialise the bus, the following are steps to achieve this: ? step 1 set the sim2~sim0 bits to "110" and simen bit to "1" in the simc0 register to enable the i 2 c bus. ? step 2 write the slave address of the device to the i 2 c bus address register sima. ? step 3 set the sime interrupt enable bit of the interrupt control register to enable the sim interrupt. set sim[2:0]=110 set simen write slave ?ddress to sim? i 2 c b?s interr?pt=? clr sime poll simf to decide when to ?o to i 2 c b?s isr no yes set sime wait for interr?pt goto main pro?ram goto main pro?ram start i 2 c b?s initialisation flow chart
rev. 1.20 106 ????st 2?? 201? rev. 1.20 10? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom i 2 c bus start signal the start signal can only be generated by the master device connected to the i 2 c bus and not by the slave device. this start signal will be detected by all devices connected to the i 2 c bus. when detected, this indicates that the i 2 c bus is busy and therefore the hbb bit will be set. a start condition occurs when a high to low transition on the sda line takes place when the scl line remains high. i 2 c slave address the transmission of a start signal by the master will be detected by all devices on the i 2 c bus. to determine which slave device the master wishes to communicate with, the address of the slave device will be sent out immediately following the start signal. all slave devices, after receiving this 7-bit address data, will compare it with their own 7-bit slave address. if the address sent out by the master matches the internal address of the microcontroller slave device, then an internal i 2 c bus interrupt signal will be generated. the next bit following the address, which is the 8 th bit, defnes the read/write status and will be saved to the srw bit of the simc1 register. the slave device will then transmit an acknowledge bit, which is a low level, as the 9 th bit. the slave device will also set the status fag haas when the addresses match. as an i 2 c bus interrupt can come from three sources, when the program enters the interrupt subroutine, the haas and simtof bits should be examined to see whether the interrupt source has come from a matching slave address, the completion of a data byte transfer or the i 2 c bus time-out occurrence. when a slave address is matched, the device must be placed in either the transmit mode and then write data to the simd register, or in the receive mode where it must implement a dummy read from the simd register to release the scl line. i 2 c bus read/write signal the srw bit in the simc1 register defnes whether the slave device wishes to read data from the i 2 c bus or write data to the i 2 c bus. the slave device should examine this bit to determine if it is to be a transmitter or a receiver. if the srw fag is "1" then this indicates that the master device wishes to read data from the i 2 c bus, therefore the slave device must be setup to send data to the i 2 c bus as a transmitter. if the srw fag is "0" then this indicates that the master wishes to send data to the i 2 c bus, therefore the slave device must be setup to read data from the i 2 c bus as a receiver. i 2 c bus slave address acknowledge signal after the master has transmitted a calling address, any slave device on the i 2 c bus, whose own internal address matches the calling address, must generate an acknowledge signal. the acknowledge signal will inform the master that a slave device has accepted its calling address. if no acknowledge signal is received by the master then a stop signal must be transmitted by the master to end the communication. when the haas fag is high, the addresses have matched and the slave device must check the srw fag to determine if it is to be a transmitter or a receiver. if the srw fag is high, the slave device should be setup to be a transmitter so the htx bit in the simc1 register should be set to "1". if the srw fag is low, then the microcontroller slave device should be setup as a receiver and the htx bit in the simc1 register should be set to "0".
rev. 1.20 10? ????st 2?? 201? rev. 1.20 109 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom i 2 c bus data and acknowledge signal the transmitted data is 8-bits wide and is transmitted after the slave device has acknowledged receipt of its slave address. the order of serial bit transmission is the msb frst and the lsb last. after receipt of 8-bits of data, the receiver must transmit an acknowledge signal, level "0", before it can receive the next data byte. if the slave transmitter does not receive an acknowledge bit signal from the master receiver, then the slave transmitter will release the sda line to allow the master to send a stop signal to release the i 2 c bus. the corresponding data will be stored in the simd register. if setup as a transmitter, the slave device must frst write the data to be transmitted into the simd register. if setup as a receiver, the slave device must read the transmitted data from the simd register. when the slave receiver receives the data byte, it must generate an acknowledge bit, known as txak, on the 9 th clock. the slave device, which is setup as a transmitter will check the rxak bit in the simc1 register to determine if it is to send another data byte, if not then it will release the sda line and await the receipt of a stop signal from the master. start scl sd? scl sd? 1 s=start (1 bit) s?=slave ?ddress (? bits) sr=srw bit (1 bit) m=slave device send acknowled?e bit (1 bit) d=data (? bits) ?=?ck (rx?k bit for transmitter? tx?k bit for receiver? 1 bit) p=stop (1 bit) 0 ?ck slave ?ddress srw stop data ?ck 1101010 10010100 s s? sr m d ? d ? s s? sr m d ? d ? p i 2 c communication timing diagram note: when a slave address is matched, the device must be placed in either the transmit mode and then write data to the simd register, or in the receive mode where it must implement a dummy read from the simd register to release the scl line.
rev. 1.20 10? ????st 2?? 201? rev. 1.20 109 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom start simtof=1? set simtoen clr simtof reti h??s=1? htx=1? srw=1? read from simd to release scl line reti rx?k=1? write data to simd to release scl line clr htx clr tx?k d?mmy read from simd to release scl line reti reti set htx write data to simd to release scl line reti clr htx clr tx?k d?mmy read from simd to release scl line reti yes no no yes yes no yes no no yes i 2 c bus isr flow chart i 2 c time-out control in order to reduce the i 2 c lockup problem due to reception of erroneous clock sources, a time-out function is provided. if the clock source connected to the i 2 c bus is not received for a while, then the i 2 c circuitry and registers will be reset after a certain time-out period. the time-out counter starts to count on an i 2 c bus "start" & "address match"condition, and is cleared by an scl falling edge. before the next scl falling edge arrives, if the time elapsed is greater than the time-out period specifed by the simtoc register, then a time-out condition will occur. the time-out function will stop when an i 2 c "stop" condition occurs.
rev. 1.20 110 ????st 2?? 201? rev. 1.20 111 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom start scl sd? scl sd? 1 0 ?ck slave ?ddress srw stop 1101010 10010100 i 2 c time-o?t co?nter start i 2 c time-o?t co?nter reset on scl ne?ative transition i 2 c time-out when an i 2 c time-out counter overfow occurs, the counter will stop and the simtoen bit will be cleared to zero and the simtof bit will be set high to indicate that a time-out condition has occurred. the time-out condition will also generate an interrupt which uses the i 2 c interrrupt vector. when an i 2 c time-out occurs, the i 2 c internal circuitry will be reset and the registers will be reset into the following condition: register after i 2 c time-out simd? sim?? simc0 no chan?e simc1 reset to por condition i 2 c register after time-out the simtof fag can be cleared by the application program. there are 64 time-out period selections which can be selected using the simtos bits in the simtoc register. the time-out duration is calculated by the formula: ((1~64) (32/f sub )). this gives a time-out period which ranges from about 1ms to 64ms. ? simtoc register bit 7 6 5 4 3 2 1 0 name simtoen simtof simtos5 simtos4 simtos3 simtos2 simtos1 simtos0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7 : sim i 2 c time-out function control 0: disable 1: enable bit 6 : sim i 2 c time-out fag 0: no time-out occurred 1: time-out occurred bit 5~0 : sim i 2 c time-out period selection i 2 c time-out clock source is f sub /32. i 2 c time-out time is equal to (simtos[5:0]+1) (32/f sub ).
rev. 1.20 110 ????st 2?? 201? rev. 1.20 111 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom scom/sseg function for lcd the device has the capability of driving external lcd panels. the common and segment pins for lcd driving, scom0~scom5 and sseg0~sseg19, are pin-shared with certain pins on the i/o ports. the lcd signals, com and seg, are generated using the application program. lcd operation an external lcd panel can be driven using the device by confguring the i/o pins as common pins and and segment pins. the lcd driver function is controlled using the lcd control registers which in addition to controlling the overall on/off function also controls the r-type bias current on the scom and sseg pins. this enables the lcd com and seg driver to generate the necessary v ss , (1/3)v dd , (2/3)v dd and v dd voltage levels for lcd 1/3 bias operation. the lcden bit in the slcdc0 register is the overall master control for the lcd driver. this bit is used in conjunction with the comnen and segmen bits to select which i/o pins are used for lcd driving. note that the corresponding port control register does not need to frst setup the pins as outputs to enable the lcd driver operation. v dd (2/3) v dd (1/3) v dd v dd lcd volta?e select circ?it lcd com/seg ?nalo? switch lcden rsel[1:0] comnen comsegsn 6 6 segmen fr?me scom0/sseg0 scom5/sseg5 sseg6 ssegm software controlled lcd driver structure lcd frames a cyclic lcd waveform includes two frames known as frame 0 and frame 1 for which the following offers a functional explanation. ? frame 0 to select frame 0, clear the frame bit in the slcdc 0 register to 0. in frame 0, the com signal output can have a value of v dd or a v bias value of (1/3) v dd . the seg signal output can have a value of v ss or a v bias value of (2/3) v dd . ? frame 1 to select frame 1, set the frame bit in the slcdc0 register to 1. in frame 1, the com signal output can have a value of v ss or a v bias value of (2/3) v dd . the seg signal output can have a value of v dd or a v bias value of (1/3) v dd .
rev. 1.20 112 ????st 2?? 201? rev. 1.20 113 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom the comn waveform is controlled by the application program using the frame bit in the slcdc0 register and the corresponding pin-shared i/o data bit for the respective com pin to determine whether the comn output has a value of v dd , v ss or v bias . the segm waveform is controlled in a similar way using the frame bit and the corresponding pin-shared i/o data bit for the respective seg pin to determine whether the segm output has a value of v dd , v ss or v bias . the accompanying waveform diagram shows a typical 1/3 bias lcd waveform gemerated using the application program together with the lcd voltage select circuit. note that the depiction of a "1" in the diagram illustrates an illuminated lcd pixel. the com signal polarity generated on pins scom0~scom5, whether "0" or "1", are generated using the corresponding pin-shared i/o data register bit. com0 v dd (2/3) v dd (1/3) v dd v ss v dd (2/3) v dd (1/3) v dd v ss com1 com2 v dd (2/3) v dd (1/3) v dd v ss v dd (2/3) v dd (1/3) v dd v ss com3 v dd (2/3) v dd (1/3) v dd v ss seg0 v dd (2/3) v dd (1/3) v dd v ss seg1 frame 0 frame 1 frame 0 frame 1 frame 0 frame 0 1 000 1 000 1 000 1 000 1 000 1 00 0 1 00 0 00 1 0 1 00 0 00 1 0 1 00 00 1 00 1 0 00 0 1 00 1 0 00 0 1 00 1 0 00 1 000 1 000 1 000 1 000 1 000 1 000 00 11 00 11 00 11 00 11 00 11 00 1 111 0 111 0 111 0 111 0 111 0 111 note: the logical values shown in the above diagram are the corresponding pin-shared i/o data bit value. 1/3 bias lcd waveform C 4-com & 2-seg application lcd control registers the lcd com and seg driver enables a range of selections to be provided to suit the requirement of the lcd panel which is being used. the bias resistor choice is implemented using the rsel1 and rsel0 bits in the slcdc0 register. all com and seg pins are pin-shared with i/o pin. register name bit 7 6 5 4 3 2 1 0 slcdc0 fr?me rsel1 rsel0 lcden com3en com2en com1en com0en slcdc1 com5en com4en comsegs5 comsegs4 comsegs3 comsegs2 comsegs1 comsegs0 slcdc2 seg13en seg12en seg11en seg10en seg9en seg?en seg?en seg6en slcdc3 seg19en seg1?en seg1?en seg16en seg15en seg14en lcd driver control registers list
rev. 1.20 112 ????st 2?? 201? rev. 1.20 113 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom slcdc0 register bit 7 6 5 4 3 2 1 0 name fr?me rsel1 rsel0 lcden com3en com2en com1en com0en r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7 frame : scom/sseg output frame selection 0: frame 0 1: frame 1 bit 6~5 rsel1~rsel0 : select scom/sseg typical bias current (v =5v) 00: 8.3 a 01: 16.7 a 10: 50 a 11: 100 a bit 4 lcden : scom/sseg module enable control 0: disable 1: enable the scomn and ssegm lines can be enabled using comnen and segmen if the lcden bit is set to 1. when the lcd bit is cleared to 0, then the scomn and ssegm outputs will be fxed at a v level. bit 3 com3en : scom3/sseg3 or other pin function select 0: other pin-shared functions 1: scom3/sseg3 function bit 2 com2en : scom2/sseg2 or other pin function select 0: other pin-shared functions 1: scom2/sseg2 function bit 1 com1en : scom1/sseg1 or other pin function select 0: other pin-shared functions 1: scom1/sseg1 function bit 0 com0en : scom0/sseg0 or other pin function select 0: other pin-shared functions 1: scom0/sseg0 function slcdc1 register bit 7 6 5 4 3 2 1 0 name com5en com4en comsegs5 comsegs4 comsegs3 comsegs2 comsegs1 comsegs0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7 com5en : scom5/sseg5 or other pin function select 0: other pin-shared functions 1: scom5/sseg5 function bit 6 com4en : scom4/sseg4 or other pin function select 0: other pin-shared functions 1: scom4/sseg4 function bit 5 comsegs5 : scom5 or sseg5 pin function select 0: scom5 1: sseg5 bit 4 comsegs4 : scom4 or sseg4 pin function select 0: scom4 1: sseg4 bit 3 comsegs3 : scom3 or sseg3 pin function select 0: scom3 1: sseg3
rev. 1.20 114 ????st 2?? 201? rev. 1.20 115 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom bit 2 comsegs2 : scom2 or sseg2 pin function select 0: scom2 1: sseg2 bit 1 comsegs1 : scom1 or sseg1 pin function select 0: scom1 1: sseg1 bit 0 comsegs0 : scom0 or sseg0 pin function select 0: scom0 1: sseg0 slcdc2 register bit 7 6 5 4 3 2 1 0 name seg13en seg12en seg11en seg10en seg9en seg?en seg?en seg6en r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7 seg13en : sseg13 pin function select 0: other pin-shared functions 1: sseg13 function bit 6 seg12en : sseg12 pin function select 0: other pin-shared functions 1: sseg12 function bit 5 seg11en : sseg11 pin function select 0: other pin-shared functions 1: sseg11 function bit 4 seg10en : sseg10 pin function select 0: other pin-shared functions 1: sseg10 function bit 3 seg9en : sseg9 pin function select 0: other pin-shared functions 1: sseg9 function bit 2 seg8en : sseg8 pin function select 0: other pin-shared functions 1: sseg8 function bit 1 seg7en : sseg7 pin function select 0: other pin-shared functions 1: sseg7 function bit 0 seg6en : sseg6 pin function select 0: other pin-shared functions 1: sseg6 function
rev. 1.20 114 ????st 2?? 201? rev. 1.20 115 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom slcdc3 register bit 7 6 5 4 3 2 1 0 name seg19en seg1?en seg1?en seg16en seg15en seg14en r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 bit 7~6 unimplemented, read as "0 bit 5 seg19en : sseg19 pin function select 0: other pin-shared functions 1: sseg19 function bit 4 seg18en : sseg18 pin function select 0: other pin-shared functions 1: sseg18 function bit 3 seg17en : sseg17 pin function select 0: other pin-shared functions 1: sseg17 function bit 2 seg16en : sseg16 pin function select 0: other pin-shared functions 1: sseg16 function bit 1 seg15en : sseg15 pin function select 0: other pin-shared functions 1: sseg15 function bit 0 seg14en : sseg14 pin function select 0: other pin-shared functions 1: sseg14 function
rev. 1.20 116 ????st 2?? 201? rev. 1.20 11 ? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom uart interface the uart interface module is contained in the device. the device contains an integrated full-duplex asynchronous serial communications uart interface that enables communication with external devices that contain a serial interface. the uart function has many features and can transmit and receive data serially by transferring a frame of data with eight or nine data bits per transmission as well as being able to detect errors when the data is overwritten or incorrectly framed. the uart function possesses its own internal interrupt which can be used to indicate when a reception occurs or when a transmission terminates. the integrated uart function contains the following features: ? full-duplex, asynchronous communication ? 8 or 9 bits character length ? even, odd or no parity options ? one or two stop bits ? baud rate generator with 8-bit prescaler ? parity, framing, noise and overrun error detection ? support for interrupt on address detect (last character bit=1) ? separately enabled transmitter and receiver ? 2-byte deep fifo receive data buffer ? rx pin wake-up function ? transmit and receive interrupts ? interrupts can be initialized by the following conditions: ? transmitter empty ? transmitter idle ? receiver full ? receiver overrun ? address mode detect msb lsb transmitter shift re?ister (tsr) msb lsb receiver shift re?ister (rsr) tx pin rx pin ba?d rate generator txr_rxr re?ister txr_rxr re?ister data to be transmitted data received b?ffer f h mcu data b?s uart data transfer block diagram
rev. 1.20 116 ????st 2?? 201? rev. 1.20 11 ? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom uart external pin to communicate with an external serial interface, the internal uart has two external pins known as tx and rx. the tx and rx pins are respectively the uart transmitter and receiver pins which are pin-shared with i/o or other pin-shared functions. along with the uarten bit, the txen and rxen bits, if set, will automatically setup these i/o pins to their respective tx output and rx input conditions and disable any pull-high resistor option which may exist on the tx and rx pins. when the tx or rx pin function is disabled by clearing the uarten, txen or rxen bit, the tx or rx pin will be used as i/o or other pin-shared functional pin depending upon the pin-shared function priority. uart data transfer scheme the above diagram shows the overall data transfer structure arrangement for the uart interface. the actual data to be transmitted from the mcu is frst transferred to the txr_rxr register by the application program. the data will then be transferred to the transmit shift register from where it will be shifted out, lsb frst, onto the tx pin at a rate controlled by the baud rate generator. only the txr_rxr register is mapped onto the mcu data memory, the transmit shift register is not mapped and is therefore inaccessible to the application program. data to be received by the uart is accepted on the external rx pin, from where it is shifted in, lsb frst, to the receiver shift register at a rate controlled by the baud rate generator. when the shift register is full, the data will then be transferred from the shift register to the internal txr_rxr register, where it is buffered and can be manipulated by the application program. only the txr_ rxr register is mapped onto the mcu data memory, the receiver shift register is not mapped and is therefore inaccessible to the application program. it should be noted that the actual register for data transmission and reception, although referred to in the text, and in application programs, as separate txr and rxr registers, only exists as a single shared register in the data memory. this shared register known as the txr_rxr register is used for both data transmission and data reception. uart status and control registers there are fve control registers associated with the uart function. the usr, ucr1 and ucr2 registers control the overall function of the uart, while the brg register controls the baud rate. the actual data to be transmitted and received on the serial interface is managed through the txr_ rxr data registers. register name bit 7 6 5 4 3 2 1 0 usr perr nf ferr oerr ridle rxif tidle txif ucr1 u? rten bno pren prt stops txbrk rx? tx? ucr2 txen rxen brgh ?dden w ?ke rie tiie teie brg brg? brg6 brg5 brg4 brg3 brg2 brg1 brg0 txr_rxr txrx? txrx6 txrx5 txrx4 txrx3 txrx2 txrx1 txrx0 uart status and control registers list
rev. 1.20 11 ? ????st 2?? 201? rev. 1.20 119 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom txr_rxr register the txr_rxr register is the data register which is used to store the data to be transmitted on the tx pin or being received from the rx pin. bit 7 6 5 4 3 2 1 0 name txrx? txrx6 txrx5 txrx4 txrx3 txrx2 txrx1 txrx0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por x x x x x x x x "x": ?nknown bit 7~0 txrx7~txrx0 : uart transmit/receive data bits usr register the usr register is the status register for the uart, which can be read by the program to determine the present status of the uart. all fags within the usr register are read only and further explanations are given below. bit 7 6 5 4 3 2 1 0 name perr nf ferr oerr ridle rxif tidle txif r/w r r r r r r r r por 0 0 0 0 1 0 1 1 bit 7 perr : parity error fag 0: no parity error is detected 1: parity error is detected the perr fag is the parity error fag. when this read only fag is "0", it indicates a parity error has not been detected. when the fag is "1", it indicates that the parity of the received word is incorrect. this error fag is applicable only if parity mode (odd or even) is selected. the fag can also be cleared by a software sequence which involves a read to the status register usr followed by an access to the txr_rxr data register. bit 6 nf : noise fag 0: no noise is detected 1: noise is detected the nf flag is the noise flag. when this read only flag is "0", it indicates no noise condition. when the fag is "1", it indicates that the uart has detected noise on the receiver input. the nf fag is set during the same cycle as the rxif fag but will not be set in the case of as overrun. the nf fag can be cleared by a software sequence which will involve a read to the status register usr followed by an access to the txr_rxr data register. bit 5 ferr : framing error fag 0: no framing error is detected 1: framing error is detected the ferr fag is the framing error fag. when this read only fag is "0", it indicates that there is no framing error. when the fag is "1", it indicates that a framing error has been detected for the current character. the fag can also be cleared by a software sequence which will involve a read to the status register usr followed by an access to the txr_rxr data register. bit 4 oerr : overrun error fag 0: no overrun error is detected 1: overrun error is detected the oerr fag is the overrun error fag which indicates when the receiver buffer has overfowed. when this read only fag is "0", it indicates that there is no overrun error. when the fag is "1", it indicates that an overrun error occurs which will inhibit further transfers to the txr_rxr receive data register. the flag is cleared by a software sequence, which is a read to the status register usr followed by an access to the txr_rxr data register.
rev. 1.20 11 ? ????st 2?? 201? rev. 1.20 119 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom bit 3 ridle : receiver status 0: data reception is in progress (data being received) 1: no data reception is in progress (receiver is idle) the ridle fag is the receiver status fag. when this read only fag is "0", it indicates that the receiver is between the initial detection of the start bit and the completion of the stop bit. when the fag is "1", it indicates that the receiver is idle. between the completion of the stop bit and the detection of the next start bit, the ridle bit is "1" indicating that the uart receiver is idle and the rx pin stays in logic high condition. bit 2 rxif : receive txr_rxr data register status 0: txr_rxr data register is empty 1: txr_rxr data register has available data the rxif fag is the receive data register status fag. when this read only fag is "0", it indicates that the txr_rxr read data register is empty. when the flag is "1", it indicates that the txr_rxr read data register contains new data. when the contents of the shift register are transferred to the txr_rxr register, an interrupt is generated if rie=1 in the ucr2 register. if one or more errors are detected in the received word, the appropriate receive-related fags nf, ferr, and/or perr are set within the same clock cycle. the rxif fag is cleared when the usr register is read with rxif set, followed by a read from the txr_rxr register, and if the txr_rxr register has no data available. bit 1 tidle : transmission status 0: data transmission is in progress (data being transmitted) 1: no data transmission is in progress (transmitter is idle) the tidle flag is known as the transmission complete flag. when this read only fag is "0", it indicates that a transmission is in progress. this fag will be set to "1" when the txif fag is "1" and when there is no transmit data or break character being transmitted. when tidle is equal to 1, the tx pin becomes idle with the pin state in logic high condition. the tidle fag is cleared by reading the usr register with tidle set and then writing to the txr_rxr register. the fag is not generated when a data character or a break is queued and ready to be sent. bit 0 txif : transmit txr_rxr data register status 0: character is not transferred to the transmit shift register 1: character has transferred to the transmit shift register (txr_rxr data register is empty) the txif fag is the transmit data register empty fag. when this read only fag is "0", it indicates that the character is not transferred to the transmitter shift register. when the fag is "1", it indicates that the transmitter shift register has received a character from the txr_rxr data register. the txif flag is cleared by reading the uart status register (usr) with txif set and then writing to the txr_rxr data register. note that when the txen bit is set, the txif fag bit will also be set since the transmit data register is not yet full.
rev. 1.20 120 ????st 2?? 201? rev. 1.20 121 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom ucr1 register the ucr1 register together with the ucr2 register are the two uart control registers that are used to set the various options for the uart function such as overall on/off control, parity control, data transfer bit length, etc. further explanation on each of the bits is given below. bit 7 6 5 4 3 2 1 0 name u? rten bno pren prt stops txbrk rx? tx? r/w r/w r/w r/w r/w r/w r/w r w por 0 0 0 0 0 0 x 0 "x": ?nknown bit 7 uarten : uart function enable control 0: disable uart; tx and rx pins are used as other pin-shared functional pins. 1: enable uart; tx and rx pins can function as uart pins defned by txen and rxen bits the uarten bit is the uart enable bit. when this bit is equal to "0", the uart will be disabled and the rx pin as well as the tx pin will be other pin-shared functional pins. when the bit is equal to "1", the uart will be enabled and the tx and rx pins will function as defned by the txen and rxen enable control bits. when the uart is disabled, it will empty the buffer so any character remaining in the buffer will be discarded. in addition, the value of the baud rate counter will be reset. if the uart is disabled, all error and status fags will be reset. also the txen, rxen, txbrk, rxif, oerr, ferr, perr and nf bits will be cleared, while the tidle, txif and ridle bits will be set. other control bits in ucr1, ucr2 and brg registers will remain unaffected. if the uart is active and the uarten bit is cleared, all pending transmissions and receptions will be terminated and the module will be reset as defned above. when the uart is re-enabled, it will restart in the same confguration. bit 6 bno : number of data transfer bits selection 0: 8-bit data transfer 1: 9-bit data transfer this bit is used to select the data length format, which can have a choice of either 8-bit or 9-bit format. when this bit is equal to "1", a 9-bit data length format will be selected. if the bit is equal to "0", then an 8-bit data length format will be selected. if 9-bit data length format is selected, then bits rx8 and tx8 will be used to store the 9th bit of the received and transmitted data respectively. bit 5 pren : parity function enable control 0: parity function is disabled 1: parity function is enabled this bit is the parity function enable bit. when this bit is equal to 1, the parity function will be enabled. if the bit is equal to 0, then the parity function will be disabled. bit 4 prt : parity type selection bit 0: even parity for parity generator 1: odd parity for parity generator this bit is the parity type selection bit. when this bit is equal to 1, odd parity type will be selected. if the bit is equal to 0, then even parity type will be selected. bit 3 stops : number of stop bits selection 0: one stop bit format is used 1: two stop bits format is used this bit determines if one or two stop bits are to be used. when this bit is equal to "1", two stop bits format are used. if the bit is equal to "0", then only one stop bit format is used.
rev. 1.20 120 ????st 2?? 201? rev. 1.20 121 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom bit 2 txbrk : transmit break character 0: no break character is transmitted 1: break characters transmit the txbrk bit is the transmit break character bit. when this bit is equal to "0", there are no break characters and the tx pin operats normally. when the bit is equal to "1", there are transmit break characters and the transmitter will send logic zeros. when this bit is equal to "1", after the buffered data has been transmitted, the transmitter output is held low for a minimum of a 13-bit length and until the txbrk bit is reset. bit 1 rx8 : receive data bit 8 for 9-bit data transfer format (read only) this bit is only used if 9-bit data transfers are used, in which case this bit location will store the 9 th bit of the received data known as rx8. the bno bit is used to determine whether data transfes are in 8-bit or 9-bit format. bit 0 tx8 : transmit data bit 8 for 9-bit data transfer format (write only) this bit is only used if 9-bit data transfers are used, in which case this bit location will store the 9 th bit of the transmitted data known as tx8. the bno bit is used to determine whether data transfes are in 8-bit or 9-bit format. ucr2 register the ucr2 register is the second of the uart control registers and serves several purposes. one of its main functions is to control the basic enable/disable operation if the uart transmitter and receiver as well as enabling the various uart interrupt sources. the register also serves to control the baud rate speed, receiver wake-up function enable and the address detect function enable. further explanation on each of the bits is given below. bit 7 6 5 4 3 2 1 0 name txen rxen brgh ?dden w ?ke rie tiie teie r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7 txen : uart transmitter enable control 0: uart transmitter is disabled 1: uart transmitter is enabled the txen bit is the transmitter enable bit. when this bit is equal to "0", the transmitter will be disabled with any pending data transmissions being aborted. in addition the buffers will be reset. in this situation the tx pin will be other pin-shared functional pin. if the txen bit is equal to "1" and the uarten bit is also equal to 1, the transmitter will be enabled and the tx pin will be controlled by the uart. clearing the txen bit during a transmission will cause the data transmission to be aborted and will reset the transmitter. if this situation occurs, the tx pin will be other pin-shared functional pin. bit 6 rxen : uart receiver enable control 0: uart receiver is disabled 1: uart receiver is enabled the rxen bit is the receiver enable bit. when this bit is equal to "0", the receiver will be disabled with any pending data receptions being aborted. in addition the receiver buffers will be reset. in this situation the rx pin will be other pin-shared functional pin. if the rxen bit is equal to "1" and the uarten bit is also equal to 1, the receiver will be enabled and the rx pin will be controlled by the uart. clearing the rxen bit during a reception will cause the data reception to be aborted and will reset the receiver. if this situation occurs, the rx pin will be other pin-shared functional pin.
rev. 1.20 122 ????st 2?? 201? rev. 1.20 123 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom bit 5 brgh : baud rate speed selection 0: low speed baud rate 1: high speed baud rate the bit named brgh selects the high or low speed mode of the baud rate generator. this bit, together with the value placed in the baud rate register, brg, controls the baud rate of the uart. if the bit is equal to 0, the low speed mode is selected. bit 4 adden : address detect function enable control 0: address detection function is disabled 1: address detection function is enabled the bit named adden is the address detection function enable control bit. when this bit is equal to 1, the address detection function is enabled. when it occurs, if the 8 th bit, which corresponds to rx7 if bno=0, or the 9 th bit, which corresponds to rx8 if bno=1, has a value of "1", then the received word will be identifed as an address, rather than data. if the corresponding interrupt is enabled, an interrupt request will be generated each time the received word has the address bit set, which is the 8 th or 9 th bit depending on the value of the bno bit. if the address bit known as the 8 th or 9 th bit of the received word is "0" with the address detection function being enabled, an interrupt will not be generated and the received data will be discarded. bit 3 wake : rx pin wake-up uart function enable control 0: rx pin wake-up uart function is disabled 1: rx pin wake-up uart function is enabled this bit is used to control the wake-up uart function when a falling edge on the rx pin occurs. note that this bit is only available when the uart clock (f h ) is switched off. there will be no rx pin wake-up uart function if the uart clock (f h ) exists. if the wake bit is set to 1 as the uart clock (f h ) is switched off, a uart wake- up request will be initiated when a falling edge on the rx pin occurs. when this request happens and the corresponding interrupt is enabled, an rx pin wake-up uart interrupt will be generated to inform the mcu to wake up the uart function by switching on the uart clock (f h ) via the application program. otherwise, the uart function can not resume even if there is a falling edge on the rx pin when the wake bit is cleared to 0. bit 2 rie : receiver interrupt enable control 0: receiver related interrupt is disabled 1: receiver related interrupt is enabled the bit enables or disables the receiver interrupt. if this bit is equal to 1 and when the receiver overrun flag oerr or received data available flag rxif is set, the uart interrupt request fag will be set. if this bit is equal to 0, the uart interrupt request fag will not be infuenced by the condition of the oerr or rxif fags. bit 1 tiie : transmitter idle interrupt enable control 0: transmitter idle interrupt is disabled 1: transmitter idle interrupt is enabled the bit enables or disables the transmitter idle interrupt. if this bit is equal to 1 and when the transmitter idle fag tidle is set, due to a transmitter idle condition, the uart interrupt request fag will be set. if this bit is equal to 0, the uart interrupt request fag will not be infuenced by the condition of the tidle fag. bit 0 teie : transmitter empty interrupt enable control 0: transmitter empty interrupt is disabled 1: transmitter empty interrupt is enabled the bit enables or disables the transmitter empty interrupt. if this bit is equal to 1 and when the transmitter empty fag txif is set, due to a transmitter empty condition, the uart interrupt request fag will be set. if this bit is equal to 0, the uart interrupt request fag will not be infuenced by the condition of the txif fag.
rev. 1.20 122 ????st 2?? 201? rev. 1.20 123 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom baud rate generator to setup the speed of the serial data communication, the uart function contains its own dedicated baud rate generator. the baud rate is controlled by its own internal free running 8-bit timer, the period of which is determined by two factors. the first of these is the value placed in the brg register and the second is the value of the brgh bit within the ucr2 control register. the brgh bit decides, if the baud rate generator is to be used in a high speed mode or low speed mode, which in turn determines the formula that is used to calculate the baud rate. the value in the brg register, n, which is used in the following baud rate calculation formula determines the division factor. note that n is the decimal value placed in the brg register and has a range of between 0 and 255. ucr2 brgh bit 0 1 ba?d rate (br) f h / [64 (n+1)] f h / [16 (n+1)] by programming the brgh bit which allows selection of the related formula and programming the required value in the brg register, the required baud rate can be setup. note that because the actual baud rate is determined using a discrete value, n, placed in the brg register, there will be an error associated between the actual and requested value. the following example shows how the brg register value n and the error value can be calculated. ? brg register bit 7 6 5 4 3 2 1 0 name brg? brg6 brg5 brg4 brg3 brg2 brg1 brg0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por x x x x x x x x "x": ?nknown bit 7~0 brg7~brg0 : baud rate values by programming the brgh bit in the ucr2 register which allows selection of the related formula described above and programming the required value in the brg register, the required baud rate can be setup. calculating the baud rate and error values for a clock frequency of 4mhz, and with brgh cleared to zero determine the brg register value n, the actual baud rate and the error value for a desired baud rate of 4800. from the above table the desired baud rate br=f h / [64 (n+1)] re-arranging this equation gives n=[f h / (br64)] - 1 giving a value for n=[4000000 / (480064)] - 1=12.0208 to obtain the closest value, a decimal value of 12 should be placed into the brg register. this gives an actual or calculated baud rate value of br=4000000 / [64 (12+1)]=4808 therefore the error is equal to (4808 - 4800) / 4800=0.16%
rev. 1.20 124 ????st 2?? 201? rev. 1.20 125 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom uart setup and control for data transfer, the uart function utilizes a non-return-to-zero, more commonly known as nrz, format. this is composed of one start bit, eight or nine data bits and one or two stop bits. parity is supported by the uart hardware and can be setup to be even, odd or no parity. for the most common data format, 8 data bits along with no parity and one stop bit, denoted as 8, n, 1, is used as the default setting, which is the setting at power-on. the number of data bits and stop bits, along with the parity, are setup by programming the corresponding bno, prt, pren and stops bits in the ucr1 register. the baud rate used to transm it and receive data is setup using the internal 8-bit baud rate generator, while the data is transmitted and received lsb frst. although the transmitter and receiver of the uart are functionally independent, they both use the same data format and baud rate. in all cases stop bits will be used for data transmission. enabling/disabling the uart interface the basic on/off function of the internal uart function is controlled using the uarten bit in the ucr1 register. if the uarten, txen and rxen bits are set, then these two uart pins will act as normal tx output pin and rx input pin respectively. if no data is being transmitted on the tx pin, then it will default to a logic high value. clearing the uarten bit will disable the tx and rx pins and these two pins will be used as i/ o or other pin-shared functional pins. when the uart function is disabled, the buffer will be reset to an empty condition, at the same time discarding any remaining residual data. disabling the uart will also reset the enable control, the error and status fags with bits txen, rxen, txbrk, rxif, oerr, ferr, perr and nf being cleared while bits tidle, txif and ridle will be set. the remaining control bits in the ucr1, ucr2 and brg registers will remain unaffected. if the uarten bit in the ucr1 register is cleared while the uart is active, then all pending transmissions and receptions will be immediately suspended and the uart will be reset to a condition as defned above. if the uart is then subsequently re-enabled, it will restart again in the same confguration. data, parity and stop bit selection the format of the data to be transferred is composed of various factors such as data bit length, parity on/off, parity type, address bits and the number of stop bits. these factors are determined by the setup of various bits within the ucr1 register. the bno bit controls the number of data bits which can be set to either 8 or 9. the prt bit controls the choice if odd or even parity. the pren bit controls the parity on/off function. the stops bit decides whether one or two stop bits are to be used. the following table shows various formats for data transmission. the address bit, which is the msb of the data byte, is used to identify the frame as an address character or data if the address detect function is enabled. the number of stop bits, which can be either one or two, is independent of the data length and is only used for the transmitter. there is only one stop bit for the receiver. start bit data bits address bits parity bit stop bit example of 8-bit data formats 1 ? 0 0 1 1 ? 0 1 1 1 ? 1 0 1 example of 9-bit data formats 1 9 0 0 1 1 ? 0 1 1 1 ? 1 0 1 transmitter receiver data format
rev. 1.20 124 ????st 2?? 201? rev. 1.20 125 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom the following diagram shows the transmit and receive waveforms for both 8-bit and 9-bit data formats. bit 0 8-bit data format bit 1 stop bit next start bit start bit parity bit bit 2 bit 3 bit 4 bit 5 bit 6 bit ? bit 0 9-bit data format bit 1 start bit bit 2 bit 3 bit 4 bit 5 bit 6 stop bit next start bit parity bit bit ? bit ? uart transmitter data word lengths of either 8 or 9 bits can be selected by programming the bno bit in the ucr1 register. when bno bit is set, the word length will be set to 9 bits. in this case the 9 th bit, which is the msb, needs to be stored in the tx8 bit in the ucr1 register. at the transmitter core lies the transmitter shift register, more commonly known as the tsr, whose data is obtained from the transmit data register, which is known as the txr_rxr register. the data to be transmitted is loaded into this txr_rxr register by the application program. the tsr register is not written to with new data until the stop bit from the previous transmission has been sent out. as soon as this stop bit has been transmitted, the tsr can then be loaded with new data from the txr_rxr register, if it is available. it should be noted that the tsr register, unlike many other registers, is not directly mapped into the data memory area and as such is not available to the application program for direct read/write operations. an actual transmission of data will normally be enabled when the txen bit is set, but the data will not be transmitted until the txr_rxr register has been loaded with data and the baud rate generator has defned a shift clock source. however, the transmission can also be initiated by frst loading data into the txr_rxr register, after which the txen bit can be set. when a transmission of data begins, the tsr is normally empty, in which case a transfer to the txr_rxr register will result in an immediate transfer to the tsr. if during a transmission the txen bit is cleared, the transmission will immediately cease and the transmitter will be reset. the tx output pin will then return to the i/o or other pin-shared function. transmitting data when the uart is transmitting data, the data is shifted on the tx pin from the shift register, with the least significant bit lsb first. in the transmit mode, the txr_rxr register forms a buffer between the internal bus and the transmitter shift register. it should be noted that if 9-bit data format has been selected, then the msb will be taken from the tx8 bit in the ucr1 register. the steps to initiate a data transfer can be summarized as follows: ? make the correct selection of the bno, prt, pren and stops bits to defne the required word length, parity type and number of stop bits. ? setup the brg register to select the desired baud rate. ? set the txen bit to ensure that the uart transmitter is enabled and the tx pin is used as a uart transmitter pin. ? access the usr register and write the data that is to be transmitted into the txr_rxr register. note that this step will clear the txif bit.
rev. 1.20 126 ????st 2?? 201? rev. 1.20 12? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom this sequence of events can now be repeated to send additional data. it should be noted that when txif=0, data will be inhibited from being written to the txr_rxr register. clearing the txif fag is always achieved using the following software sequence: 1. a usr register access 2. a txr_rxr register write execution the read-only txif flag is set by the uart hardware and if set indicates that the txr_rxr register is empty and that other data can now be written into the txr_rxr register without overwriting the previous data. if the teie bit is set, then the txif fag will generate an interrupt. during a data transmission, a write instruction to the txr_rxr register will place the data into the txr_rxr register, which will be copied to the shift register at the end of the present transmission. when there is no data transmission in progress, a write instruction to the txr_rxr register will place the data directly into the shift register, resulting in the commencement of data transmission, and the txif bit being immediately set. when a frame transmission is complete, which happens after stop bits are sent or after the break frame, the tidle bit will be set. to clear the tidle bit the following software sequence is used: 1. a usr register access 2. a txr_rxr register write execution note that both the txif and tidle bits are cleared by the same software sequence. transmitting break if the txbrk bit is set, then the break characters will be sent on the next transmission. break character transmission consists of a start bit, followed by 13xn "0" bits, where n=1, 2, etc. if a break character is to be transmitted, then the txbrk bit must be frst set by the application program and then cleared to generate the stop bits. transmitting a break character will not generate a transmit interrupt. note that a break condition length is at least 13 bits long. if the txbrk bit is continually kept at a logic high level, then the transmitter circuitry will transmit continuous break characters. after the application program has cleared the txbrk bit, the transmitter will fnish transmitting the last break character and subsequently send out one or two stop bits. the automatic logic high at the end of the last break character will ensure that the start bit of the next frame is recognized. uart receiver the uart is capable of receiving word lengths of either 8 or 9 bits can be selected by programming the bno bit in the ucr1 register. when bno bit is set, the word length will be set to 9 bits. in this case the 9 th bit, which is the msb, will be stored in the rx8 bit in the ucr1 register. at the receiver core lies the receiver shift register more commonly known as the rsr. the data which is received on the rx external input pin is sent to the data recovery block. the data recovery block operating speed is 16 times that of the baud rate, while the main receive serial shifter operates at the baud rate. after the rx pin is sampled for the stop bit, the received data in rsr is transferred to the receive data register, if the register is empty. the data which is received on the external rx input pin is sampled three times by a majority detect circuit to determine the logic level that has been placed onto the rx pin. it should be noted that the rsr register, unlike many other registers, is not directly mapped into the data memory area and as such is not available to the application program for direct read/write operations.
rev. 1.20 126 ????st 2?? 201? rev. 1.20 12? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom receiving data when the uart receiver is receiving data, the data is serially shifted in on the external rx input pin to the shift register, with the least signifcant bit lsb frst. the txr_rxr register is a two byte deep fifo data buffer, where two bytes can be held in the fifo while the 3 rd byte can continue to be received. note that the application program must ensure that the data is read from txr_rxr before the 3 rd byte has been completely shifted in, otherwise the 3 rd byte will be discarded and an overrun error oerr will be subsequently indicated. the steps to initiate a data transfer can be summarized as follows: ? make the correct selection of the bno, prt and pren bits to defne the required word length and parity type. ? setup the brg register to select the desired baud rate. ? set the rxen bit to ensure that the uart receiver is enabled and the rx pin is used as a uart receiver pin. at this point the receiver will be enabled which will begin to look for a start bit. when a character is received, the following sequence of events will occur: ? the rxifn bit in the unsr register will be set when the txr_rxrn register has data available. there will be at most one more character available before an overrun error occurs. ? when the contents of the shift register have been transferred to the txr_rxr register and if the rie bit is set, then an interrupt will be generated. ? if during reception, a frame error, noise error, parity error or an overrun error has been detected, then the error fags can be set. the rxif bit can be cleared using the following software sequence: 1. a usr register access 2. a txr_rxr register read execution receiving break any break character received by the uart will be managed as a framing error. the receiver will count and expect a certain number of bit times as specifed by the values programmed into the bno plus one stop bit. if the break is much longer than 13 bit times, the reception will be considered as complete after the number of bit times specifed by bno plus one stop bit. the rxif bit is set, ferr is set, zeros are loaded into the receive data register, interrupts are generated if appropriate and the ridle bit is set. a break is regarded as a character that contains only zeros with the ferr fag being set. if a long break signal has been detected, the receiver will regard it as a data frame including a start bit, data bits and the invalid stop bit and the ferr fag will be set. the receiver must wait for a valid stop bit before looking for the next start bit. the receiver will not make the assumption that the break condition on the line is the next start bit. the break character will be loaded into the buffer and no further data will be received until stop bits are received. it should be noted that the ridle read only fag will go high when the stop bits have not yet been received. the reception of a break character on the uart registers will result in the following: ? the framing error fag, ferr, will be set. ? the receive data register, txr_rxr, will be cleared. ? the oerr, nf, perr, ridle or rxif fags will possibly be set.
rev. 1.20 12? ????st 2?? 201? rev. 1.20 129 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom idle status when the receiver is reading data, which means it will be in between the detection of a start bit and the reading of a stop bit, the receiver status fag in the usr register, otherwise known as the ridle fag, will have a zero value. in between the reception of a stop bit and the detection of the next start bit, the ridle fag will have a high value, which indicates the receiver is in an idle condition. receiver interrupt the read only receive interrupt fag, rxif, in the usr register is set by an edge generated by the receiver. an interrupt is generated if rie=1, when a word is transferred from the receive shift register, rsr, to the receive data register, txr_rxr. an overrun error can also generate an interrupt if rie=1. m anaging receiver errors several types of reception errors can occur within the uart module, the following section describes the various types and how they are managed by the uart. overrun error C oerr the txr_rxr register is composed of a two byte deep fifo data buffer, where two bytes can be held in the fifo register, while a 3 th byte can continue to be received. before the 3 th byte has been entirely shifted in, the data should be read from the txr_rxr register. if this is not done, the overrun error fag oerr will be consequently indicated. in the event of an overrun error occurring, the following will happen: ? the oerr fag in the usr register will be set. ? the txr_rxr contents will not be lost. ? the shift register will be overwritten. ? an interrupt will be generated if the rie bit is set. the oerr fag can be cleared by an access to the usr register followed by a read to the txr_ rxr register. noise error C nf over-sampling is used for data recovery to identify valid incoming data and noise. if noise is detected within a frame, the following will occur: ? the read only noise fag, nf, in the usr register will be set on the rising edge of the rxif bit. ? data will be transferred from the shift register to the txr_rxr register. ? no interrupt will be generated. however this bit rises at the same time as the rxif bit which itself generates an interrupt. note that the nf fag is reset by a usr register read operation followed by a txr_rxr register read operation. framing error C ferr the read only framing error fag, ferr, in the usr register, is set if a zero is detected instead of stop bits. if two stop bits are selected, both stop bits must be high. otherwise the ferr fag will be set. the ferrn fag and the received data will be recorded in the usr and txr_rxr registers respectively, and the fag is cleared in any reset.
rev. 1.20 12? ????st 2?? 201? rev. 1.20 129 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom parity error C perr the read only parity error fag, perr, in the usr register, is set if the parity of the received word is incorrect. this error fag is only applicable if the parity function is enabled, pren=1, and if the parity type, odd or even, is selected. the read only perr fag is buffered along with the received data bytes. it is cleared on any reset, it should be noted that the fags, ferr and perr, and the corresponding word will be recorded in the usr and txr_rxr registers respectively. the fags in the usr register should frst be read by application program before reading the data word. uart interrupt structure several individual uart conditions can generate a uart interrupt. when these conditions exist, a low pulse will be generated to get the attention of the microcontroller. these conditions are a transmitter data register empty, transmitter idle, receiver data available, receiver overrun, address detect and an rx pin wake-up. when any of these conditions are created, if its corresponding interrupt control is enabled and the stack is not full, the program will jump to its corresponding interrupt vector where it can be serviced before returning to the main program. four of these conditions have the corresponding usr register fags which will generate a uart interrupt if its associated interrupt enable control bit in the ucr2 register is set. the two transmitter interrupt conditions have their own corresponding enable control bits, while the two receiver interrupt conditions have a shared enable control bit. these enable bits can be used to mask out individual uart interrupt sources. the address detect condition, which is also a uart interrupt source, does not have an associated flag, but will generate a uart interrupt when an address detect condition occurs if its function is enabled by setting the adden bit in the ucr2 register. an rx pin wake-up, which is also a uart interrupt source, does not have an associated fag, but will generate a uart interrupt if the microcontroller is woken up from idle0 or sleep mode by a falling edge on the rx pin, if the wake and rie bits in the ucr2 register are set. note that in the event of an rx wake-up interrupt occurring, there will be a certain period of delay, commonly known as the system start-up time, for the oscillator to restart and stabilize before the system resumes normal operation. note that the usr register flags are read only and cannot be cleared or set by the application program, neither will they be cleared when the program jumps to the corresponding interrupt servicing routine, as is the case for some of the other interrupts. the flags will be cleared automatically when certain actions are taken by the uart, the details of which are given in the uart register section. the overall uart interrupt can be disabled or enabled by the related interrupt enable control bits in the interrupt control registers of the microcontroller to decide whether the interrupt requested by the uart module is masked out or allowed.
rev. 1.20 130 ????st 2?? 201? rev. 1.20 131 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom transmitter empty fla? txif usr re?ister transmitter idle fla? tidle receiver overr?n fla? oerr receiver data ?vailable rxif ?dden rx pin wake-?p w?ke 0 1 0 1 rx? if bno=0 rx? if bno=1 ucr2 re?ister rie 0 1 tiie 0 1 teie 0 1 u?rt interr?pt req?est fla? u?rtf ucr2 re?ister u?rte emi 0 1 interr?pt si?nal to mcu uart interrupt structure address detect mode setting the address detect function enable control bit, adden, in the ucr2 register, enables this special function. if this bit is set to 1, then an additional qualifer will be placed on the generation of a receiver data available interrupt, which is requested by the rxif flag. if the adden bit is equal to 1, then when the data is available, an interrupt will only be generated, if the highest received bit has a high value. note that the related interrupt enable control bit and the emi bit of the microcontroller must also be enabled for correct interrupt generation. the highest address bit is the 9 th bit if the bit bno=1 or the 8 th bit if the bit bno=0. if the highest bit is high, then the received word will be defned as an address rather than data. a data available interrupt will be generated every time the last bit of the received word is set. if the adden bit is equal to 0, then a receive data available interrupt will be generated each time the rxif fag is set, irrespective of the data last bit status. the address detection and parity functions are mutually exclusive functions. therefore, if the address detect function is enabled, then to ensure correct operation, the parity function should be disabled by resetting the parity function enable bit pren to zero. adden bit 9 if bno=1 bit 8 if bno=0 uart interrupt generated 0 0 1 1 0 1 adden bit function
rev. 1.20 130 ????st 2?? 201? rev. 1.20 131 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom uart power down and wake-up when the uart clock (f h ) is off , the uart will cease to function, all clock sources to the module are shutdown. if the uart clock (f h ) is off while a transmission is still in progress, then the transmission will be paused until the uart clock source derived from the microcontroller is activated. in a similar way, if the mcu enters the power down mode while receiving data, then the reception of data will likewise be paused. when the mcu enters the power down mode , note that the usr, ucr1, ucr2, transmit and receive registers, as well as the brg register will not be affected. it is recommended to make sure frst that the uart data transmission or reception has been fnished before the microcontroller enters the power down mode . the uart function contains a receiver rx pin wake-up function, which is enabled or disabled by the wake bit in the ucr2 register. if this bit, along with the uart enable bit, uarten, the receiver enable bit, rxen and the receiver interrupt bit, rie, are all set when the uart clock (f h ) is off , then a falling edge on the rx pin will trigger an rx pin wake-up uart interrupt. note that as it takes certain system clock cycles after a wake-up, before normal microcontroller operation resumes, any data received during this time on the rx pin will be ignored. for a uart wake-up interrupt to occur, in addition to the bits for the wake-up being set, the global interrupt enable bit, emi, and the uart interrupt enable bit, uarte, must be set. if the emi and uarte bits are not set then only a wake up event will occur and no interrupt will be generated. note also that as it takes certain system clock cycles after a wake-up before normal microcontroller resumes, the uart interrupt will not be generated until after this time has elapsed.
rev. 1.20 132 ????st 2?? 201? rev. 1.20 133 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom low voltage detector C lvd each device has a low voltage detector function, also known as lvd. this enabled the device to monitor the power supply voltage, v dd , and provide a warning signal should it fall below a certain level. this function may be especially useful in battery applications where the supply voltage will gradually reduce as the battery ages, as it allows an early warning battery low signal to be generated. the low voltage detector also has the capability of generating an interrupt signal. lvd register the low voltage detector function is controlled using a single register with the name lvdc. three bits in this register, vlvd2~vlvd0, are used to select one of eight fxed voltages below which a low voltage condition will be determined. a low voltage condition is indicated when the lvdo bit is set. if the lvdo bit is low, this indicates that the v dd voltage is above the preset low voltage value. the lvden bit is used to control the overall on/off function of the low voltage detector. setting the bit high will enable the low voltage detector. clearing the bit to zero will switch off the internal low voltage detector circuits. as the low voltage detector will consume a certain amount of power, it may be desirable to switch off the circuit when not in use, an important consideration in power sensitive battery powered applications. lvdc register bit 7 6 5 4 3 2 1 0 name lvdo lvden vlvd2 vlvd1 vlvd0 r/w r r/w r/w r/w r/w por 0 0 0 0 0 bit 7~6 unimplemented, read as "0" bit 5 : lvd output fag 0: no low voltage detected 1: low voltage detected bit 4 : low voltage detector enable control 0: disable 1: enable bit 3 unimplemented, read as "0" bit 2~0 : lvd voltage selection 000: 2.0v 001: 2.2v 010: 2.4v 011: 2.7v 100: 3.0v 101: 3.3v 110: 3.6v 111: 4.0v
rev. 1.20 132 ????st 2?? 201? rev. 1.20 133 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom lvd operation the low voltage detector function operates by comparing the power supply voltage, v dd , with a pre-specifed voltage level stored in the lvdc register. this has a range of between 2.0v and 4.0v. when the power supply voltage, v dd , falls below this pre-determined value, the lvdo bit will be set high indicating a low power supply voltage condition. the low voltage detector function is supplied by a reference voltage which will be automatically enabled. when the device is powered down the low voltage detector will remain active if the lvden bit is high. after enabling the low voltage detector, a time delay t lvds should be allowed for the circuitry to stabilise before reading the lvdo bit. note also that as the v dd voltage may rise and fall rather slowly, at the voltage nears that of v lvd , there may be multiple bit lvdo transitions. v dd lvden lvdo v lvd t lvds lvd operation the low voltage detector also has its own interrupt which is contained within one of the multi- function interrupts, providing an alternative means of low voltage detection, in addition to polling the lvdo bit. the interrupt will only be generated after a delay of t lvd after the lvdo bit has been set high by a low voltage condition. when the device is powered down the low voltage detector will remain active if the lvden bit is high. in this case, the lvf interrupt request fag will be set, causing an interrupt to be generated if v dd falls below the preset lvd voltage. this will cause the device to wake-up from the sleep or idle mode, however if the low voltage detector wake up function is not required then the lvf fag should be frst set high before the device enters the sleep or idle mode.
rev. 1.20 134 ????st 2?? 201? rev. 1.20 135 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom interrupts interrupts are an important part of any microcontroller system. when an external event or an internal function such as a timer module or an a/d converter requires microcontroller attention, their corresponding interrupt will enforce a temporary suspension of the main program allowing the microcontroller to direct attention to their respective needs. the device contains several external interrupt and internal interrupts functions. the external interrupts are generated by the action of the external int0 and int1 pins, while the internal interrupts are generated by various internal functions such as the tms, time base, lvd, eeprom, sim, uart and the a/d converter, etc. interrupt registers overall interrupt control, which basically means the setting of request flags when certain microcontroller conditions occur and the setting of interrupt enable bits by the application program, is controlled by a series of registers, located in the special purpose data memory, as shown in the accompanying table. the number of registers depends upon the device chosen but fall into three categories. the frst is the intc0~intc2 registers which setup the primary interrupts, the second is the mfi0~mfi2 registers which setup the multi-function interrupts. finally there is an integ register to setup the external interrupt trigger edge type. each register contains a number of enable bits to enable or disable individual interrupts as well as interrupt fags to indicate the presence of an interrupt request. the naming convention of these follows a specifc pattern. first is listed an abbreviated interrupt type, then the (optional) number of that interrupt followed by either an "e" for enable/disable bit or "f" for request fag. function enable bit request flag notes global emi intn pins intne intnf n=0 ~ 1 m?lti-f?nction mfne mfnf n=0 ~ 2 ?/d converter ?de ?df time base tbne tbnf n=0 ~ 1 sim sime simf u? rt u? rte u? rtf lvd lve lvf eeprom dee def tm tnpe tnpf n=0 ~ 1 tn?e tn?f n=0 ~ 1 interrupt register bit naming conventions register name bit 7 6 5 4 3 2 1 0 integ int1s1 int1s0 int0s1 int0s0 intc0 mf0f int0f mf0e int0e emi intc1 tb0f ?df mf2f mf1f tb0e ?de mf2e mf1e intc2 u? rtf simf int1f tb1f u? rte sime int1e tb1e mfi0 t0?f t0pf t0?e t0pe mfi1 t1?f t1pf t1?e t1pe mfi2 def lvf dee lve interrupt registers list
rev. 1.20 134 ????st 2?? 201? rev. 1.20 135 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom integ register bit 7 6 5 4 3 2 1 0 name int1s1 int1s0 int0s1 int0s0 r/w r/w r/w r/w r/w por 0 0 0 0 bit 7~4 unimplemented, read as "0" bit 3~2 int1s1~int1s0 : interrupt edge control for int1 pin 00: disable 01: rising edge 10: falling edge 11: rising and falling edges bit 1~0 int0s1~int0s0 : interrupt edge control for int0 pin 00: disable 01: rising edge 10: falling edge 11: rising and falling edges intc0 register bit 7 6 5 4 3 2 1 0 name mf0f int0f mf0e int0e emi r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 bit 7 unimplemented, read as "0" bit 6 mf0f : multi-function 0 interrupt request fag 0: no request 1: interrupt request bit 5 unimplemented, read as "0" bit 4 int0f : int0 interrupt request fag 0: no request 1: interrupt request bit 3 mf0e : multi-function 0 interrupt control 0: disable 1: enable bit 2 unimplemented, read as "0" bit 1 int0e : int0 interrupt control 0: disable 1: enable bit 0 emi : global interrupt control 0: disable 1: enable
rev. 1.20 136 ????st 2?? 201? rev. 1.20 13? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom intc1 register bit 7 6 5 4 3 2 1 0 name tb0f ?df mf2f mf1f tb0e ?de mf2e mf1e r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7 tb0f : time base 0 interrupt request fag 0: no request 1: interrupt request bit 6 adf : a/d converter interrupt request fag 0: no equest 1: interrupt request bit 5 mf2f : multi-function 2 interrupt request fag 0: no equest 1: interrupt request bit 4 mf1f : multi-function 1 interrupt request fag 0: no equest 1: interrupt request bit 3 tb0e : time base 0 interrupt control 0: disable 1: enable bit 2 ade : a/d converter interrupt control 0: disable 1: enable bit 1 mf2e : multi-function 2 interrupt control 0: disable 1: enable bit 0 mf1e : multi-function 1 interrupt control 0: disable 1: enable intc2 register bit 7 6 5 4 3 2 1 0 name u? rtf simf int1f tb1f u? rte sime int1e tb1e r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7 uartf : uart interrupt request fag 0: no equest 1: interrupt request bit 6 simf : sim interrupt request fag 0: no equest 1: interrupt request bit 5 int1f : int1 interrupt request fag 0: no equest 1: interrupt request bit 4 tb1f : time base 1 interrupt request fag 0: no equest 1: interrupt request bit 3 uarte : uart interrupt control 0: disable 1: enable
rev. 1.20 136 ????st 2?? 201? rev. 1.20 13? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom bit 2 sime : sim interrupt control 0: disable 1: enable bit 1 int1e : int1 interrupt control 0: disable 1: enable bit 0 tb1e : time base 1 interrupt control 0: disable 1: enable mfi0 register bit 7 6 5 4 3 2 1 0 name t0?f t0pf t0?e t0pe r/w r/w r/w r/w r/w por 0 0 0 0 bit 7~6 unimplemented, read as "0" bit 5 t0af : tm0 comparator a match interrupt request fag 0: no equest 1: interrupt request bit 4 t0pf : tm0 comparator p match interrupt request fag 0: no equest 1: interrupt request bit 3~2 unimplemented, read as "0" bit 1 t0ae : tm0 comparator a match interrupt control 0: disable 1: enable bit 0 t0pe : tm0 comparator p match interrupt control 0: disable 1: enable mfi1 register bit 7 6 5 4 3 2 1 0 name t1?f t1pf t1?e t1pe r/w r/w r/w r/w r/w por 0 0 0 0 bit 7~6 unimplemented, read as "0" bit 5 t1af : tm1 comparator a match interrupt request fag 0: no equest 1: interrupt request bit 4 t1pf : tm1 comparator p match interrupt request fag 0: no equest 1: interrupt request bit 3~2 unimplemented, read as "0" bit 1 t1ae : tm1 comparator a match interrupt control 0: disable 1: enable bit 0 t1pe : tm1 comparator p match interrupt control 0: disable 1: enable
rev. 1.20 13? ????st 2?? 201? rev. 1.20 139 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom mfi2 register bit 7 6 5 4 3 2 1 0 name def lvf dee lve r/w r/w r/w r/w r/w por 0 0 0 0 bit 7~6 unimplemented, read as "0" bit 5 def : data eeprom interrupt request fag 0: no equest 1: interrupt request bit 4 lvf : lvd interrupt request fag 0: no equest 1: interrupt request bit 3~2 unimplemented, read as "0" bit 1 dee : data eeprom interrupt control 0: disable 1: enable bit 0 lve : lvd interrupt control 0: disable 1: enable interrupt operation when the conditions for an interrupt event occur, such as a tm comparator p or comparator a or a/d conversion completion, etc, the relevant interrupt request fag will be set. whether the request fag actually generates a program jump to the relevant interrupt vector is determined by the condition of the interrupt enable bit. if the enable bit is set high then the program will jump to its relevant vector; if the enable bit is zero then although the interrupt request fag is set an actual interrupt will not be generated and the program will not jump to the relevant interrupt vector. the global interrupt enable bit, if cleared to zero, will disable all interrupts. when an interrupt is generated, the program counter, which stores the address of the next instruction to be executed, will be transferred onto the stack. the program counter will then be loaded with a new address which will be the value of the corresponding interrupt vector. the microcontroller will then fetch its next instruction from this interrupt vector. the instruction at this vector will usually be a jmp which will jump to another section of program which is known as the interrupt service routine. here is located the code to control the appropriate interrupt. the interrupt service routine must be terminated with a reti, which retrieves the original program counter address from the stack and allows the microcontroller to continue with normal execution at the point where the interrupt occurred. the various interrupt enable bits, together with their associated request flags, are shown in the accompanying diagrams with their order of priority. some interrupt sources have their own individual vector while others share the same multi-function interrupt vector. once an interrupt subroutine is serviced, all other interrupts will be blocked, as the global interrupt enable bit, emi bit will be cleared automatically. this will prevent any further interrupt nesting from occurring. however, if other interrupt requests occur during this interval, although the interrupt will not be immediately serviced, the request fag will still be recorded.
rev. 1.20 13? ????st 2?? 201? rev. 1.20 139 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom if an interrupt requires immediate servicing while the program is already in another interrupt service routine, the emi bit should be set after entering the routine to allow interrupt nesting. if the stack is full, the interrupt request will not be acknowledged, even if the related interrupt is enabled, until the stack pointer is decremented. if immediate service is desired, the stack must be prevented from becoming full. in case of simultaneous requests, the accompanying diagram shows the priority that is applied. all of the interrupt request fags when set will wake-up the device if it is in sleep or idle mode, however to prevent a wake-up from occurring the corresponding fag should be set before the device is in sleep or idle mode. int0 pin int1 pin int0f int1f int0e int1e emi 04h emi m. f?nct. 0 mf0f mf0e emi 0ch emi 10h 14h time base 0 tb0f tb0e emi 1?h lvd lvf lve emi 1ch interr?pt name req?est fla?s enable bits master enable vector emi a?to disabled in isr priority hi?h low m. f?nct. 1 mf1f mf1e tm0 p t0pf t0pe tm0 ? t0?f t0?e interr?pts contained within m?lti-f?nction interr?pts xxe enable bits xxf req?est fla?? a?to reset in isr legend xxf req?est fla?? no a?to reset in isr emi 20h ?/d ?df ?de emi 24h m. f?nct. 2 mf2f mf2e time base 1 tb1f tb1e tm1 p t1pe tm1 ? t1?e eeprom def dee sim simf sime emi 2?h t1pf t1?f u?rt u?rtf u?rte emi 2ch interrupt scheme
rev. 1.20 140 ????st 2?? 201? rev. 1.20 141 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom external interrupt the external interrupts are controlled by signal transitions on the pins int0~int1. an external interrupt request will take place when the external interrupt request fags, int0f~int1f, are set, which will occur when a transition, whose type is chosen by the edge select bits, appears on the external interrupt pins. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, and respective external interrupt enable bit, int0e~int1e, must first be set. additionally the correct interrupt edge type must be selected using the integ register to enable the external interrupt function and to choose the trigger edge type. as the external interrupt pins are pin-shared with i/o pins, they can only be confgured as external interrupt pins if their external interrupt enable bit in the corresponding interrupt register has been set and the external interrupt pin is selected by the corresponding pin-shared function selection bits. the pin must also be setup as an input by setting the corresponding bit in the port control register. when the interrupt is enabled, the stack is not full and the correct transition type appears on the external interrupt pin, a subroutine call to the external interrupt vector, will take place. when the interrupt is serviced, the external interrupt request fags, int0f~int1f, will be automatically reset and the emi bit will be automatically cleared to disable other interrupts. note that any pull-high resistor selections on the external interrupt pins will remain valid even if the pin is used as an external interrupt input. the integ register is used to select the type of active edge that will trigger the external interrupt. a choice of either rising or falling or both edge types can be chosen to trigger an external interrupt. note that the integ register can also be used to disable the external interrupt function. multi-function interrupt within the device there are up to three multi-function interrupts. unlike the other independent interrupts, these interrupts have no independent source, but rather are formed from other existing interrupt sources, namely the tm interrupts, lvd interrupt and eeprom write operation interrupt. a multi-function interrupt request will take place when any of the multi-function interrupt request flags mfnf are set. the multi-function interrupt flags will be set when any of their included functions generate an interrupt request fag. to allow the program to branch to its respective interrupt vector address, when the multi-function interrupt is enabled and the stack is not full, and either one of the interrupts contained within each of multi-function interrupt occurs, a subroutine call to one of the multi-function interrupt vectors will take place. when the interrupt is serviced, the related multi- function request fag will be automatically reset and the emi bit will be automatically cleared to disable other interrupts. however, it must be noted that, although the multi-function interrupt request flags will be automatically reset when the interrupt is serviced, the request flags from the original source of the multi-function interrupts will not be automatically reset and must be manually reset by the application program. a/d converter interrupt the a/d converter interrupt is controlled by the termination of an a/d conversion process. an a/d converter interrupt request will take place when the a/d converter interrupt request fag, adf, is set, which occurs when the a/d conversion process fnishes. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, and a/d interrupt enable bit, ade, must frst be set. when the interrupt is enabled, the stack is not full and the a/d conversion process has ended, a subroutine call to the a/d converter interrupt vector, will take place. when the interrupt is serviced, the a/d converter interrupt fag, adf, will be automatically cleared. the emi bit will also be automatically cleared to disable other interrupts.
rev. 1.20 140 ????st 2?? 201? rev. 1.20 141 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom time base interrupt the function of the time base interrupts is to provide regular time signal in the form of an internal interrupt. they are controlled by the overfow signals from their respective timer functions. when these happens their respective interrupt request flags, tb0f or tb1f will be set. to allow the program to branch to their respective interrupt vector addresses, the global interrupt enable bit, emi and time base enable bits, tb0e or tb1e, must frst be set. when the interrupt is enabled, the stack is not full and the time base overfows, a subroutine call to their respective vector locations will take place. when the interrupt is serviced, the respective interrupt request fag, tb0f or tb1f, will be automatically reset and the emi bit will be cleared to disable other interrupts. the purpose of the time base interrupt is to provide an interrupt signal at fxed time periods. their clock sources originate from the internal clock source f tb . this f tb input clock passes through a divider, the division ratio of which is selected by programming the appropriate bits in the tbc register to obtain longer interrupt periods whose value ranges. the clock source that generates f tb , which in turn controls the time base interrupt period, can originate from several different sources, as shown in the system operating mode section. m u x f sys /4 f tbc prescaler tbck f tb f tb /2 ? ~ f tb /2 15 m u x tb11~tb10 time base 0 interr?pt time base 1 interr?pt tb02~tb00 prescaler m u x f tb /2 12 ~ f tb /2 15 time base interrupts tbc register bit 7 6 5 4 3 2 1 0 name tbon tbck tb11 tb10 lxtlp tb02 tb01 tb00 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 1 1 0 1 1 1 bit 7 tbon : time base function enable control 0: disable 1: enable bit 6 tbck : time base clock source select 0: tbc 1: /4 bit 5~4 tb11~tb10 : time base 1 time-out period selection 00: 2 12 /f tb 01: 2 13 /f tb 10: 2 14 /f tb 11: 2 15 /f tb bit 3 lxtlp :lxt low power control 0: disable 1: enable bit 2~0 tb02~tb00 : time base 0 time-out period selection 000: 2 8 /f tb 001: 2 9 /f tb 010: 2 10 /f tb 011: 2 /f tb 100: 2 12 /f tb 101: 2 13 /f tb 110: 2 14 /f tb 111: 2 15 /f tb
rev. 1.20 142 ????st 2?? 201? rev. 1.20 143 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom serial interface module interrupt the serial interface module interrupt, also known as the sim interrupt, is controlled by the spi or i 2 c data transfer. a sim interrupt request will take place when the sim interrupt request fag, simf, is set, which occurs when a byte of data has been received or transmitted by the sim interface, an i 2 c slave address match or i 2 c bus time-out occurrence. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi and the serial interface interrupt enable bit, sime, must frst be set. when the interrupt is enabled, the stack is not full and any of the above described situations occurs, a subroutine call to the respective sim interrupt vector, will take place. when the serial interface interrupt is serviced, the emi bit will be automatically cleared to disable other interrupts. the simf fag will also be automatically cleared. uart transfer interrupt the uart transfer interrupt is controlled by several uart transfer conditions. when one of these conditions occurs, an interrupt pulse will be generated to get the attention of the microcontroller. these conditions are a transmitter data register empty, transmitter idle, receiver data available, receiver overrun, address detect and an rx pin wake-up. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, and uart interrupt enable bit, uarte, must frst be set. when the interrupt is enabled, the stack is not full and any of the conditions described above occurs, a subroutine call to the uart interrupt vector, will take place. when the interrupt is serviced, the uart interrupt fag, uartf, will be automatically cleared. the emi bit will also be automatically cleared to disable other interrupts. however, the usr register fags will only be cleared when certain actions are taken by the uart, the details of which are given in the uart chapter. lvd interrupt the low voltage detector interrupt is contained within the multi-function interrupt. an lvd interrupt request will take place when the lvd interrupt request flag, lvf, is set, which occurs when the low voltage detector function detects a low power supply voltage. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, low voltage interrupt enable bit, lve, and associated multi-function interrupt enable bit, must frst be set. when the interrupt is enabled, the stack is not full and a low voltage condition occurs, a subroutine call to the multi-function interrupt vector, will take place. when the low voltage interrupt is serviced, the emi bit will be automatically cleared to disable other interrupts. however, only the multi-function interrupt request fag will be also automatically cleared. as the lvf fag will not be automatically cleared, it has to be cleared by the application program. eeprom interrupt the eeprom write interrupt is contained within the multi-function interrupt. an eeprom write interrupt request will take place when the eeprom write interrupt request fag, def, is set, which occurs when an eeprom write cycle ends. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, eeprom write interrupt enable bit, dee, and associated multi-function interrupt enable bit must first be set. when the interrupt is enabled, the stack is not full and an eeprom write cycle ends, a subroutine call to the respective multi-function interrupt vector will take place. when the eeprom write interrupt is serviced, the emi bit will be automatically cleared to disable other interrupts. however, only the multi-function interrupt request flag will be automatically cleared. as the def flag will not be automatically cleared, it has to be cleared by the application program.
rev. 1.20 142 ????st 2?? 201? rev. 1.20 143 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom tm interrupt the periodic tms have two interrupts, one comes from the comparator a match situation and the other comes from the comparator p match situation. all of the tm interrupts are contained within the multi-function interrupts. there are two interrupt request fags and two enable control bits. a tm interrupt request will take place when any of the tm request fags are set, a situation which occurs when a tm comparator p or a match situation happens. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, respective tm interrupt enable bit, and relevant multi-function interrupt enable bit, mfne, must frst be set. when the interrupt is enabled, the stack is not full and a tm comparator match situation occurs, a subroutine call to the relevant multi-function interrupt vector locations, will take place. when the tm interrupt is serviced, the emi bit will be automatically cleared to disable other interrupts. however, only the related mfnf fag will be automatically cleared. as the tm interrupt request fags will not be automatically cleared, they have to be cleared by the application program. interrupt wake-up function each of the interrupt functions has the capability of waking up the microcontroller when in the sleep or idle mode. a wake-up is generated when an interrupt request fag changes from low to high and is independent of whether the interrupt is enabled or not. therefore, even though the device is in the sleep or idle mode and its system oscillator stopped, situations such as external edge transitions on the external interrupt pins, a low power supply voltage or comparator input change may cause their respective interrupt fag to be set high and consequently generate an interrupt. care must therefore be taken if spurious wake-up situations are to be avoided. if an interrupt wake-up function is to be disabled then the corresponding interrupt request fag should be set high before the device enters the sleep or idle mode. the interrupt enable bits have no effect on the interrupt wake-up function.
rev. 1.20 144 ????st 2?? 201? rev. 1.20 145 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom programming considerations by disabling the relevant interrupt enable bits, a requested interrupt can be prevented from being serviced, however, once an interrupt request flag is set, it will remain in this condition in the interrupt register until the corresponding interrupt is serviced or until the request fag is cleared by the application program. where a certain interrupt is contained within a multi-function interrupt, then when the interrupt service routine is executed, as only the multi-function interrupt request flags, mfnf, will be automatically cleared, the individual request flag for the function needs to be cleared by the application program. it is recommended that programs do not use the "call" instruction within the interrupt service subroutine. interrupts often occur in an unpredictable manner or need to be serviced immediately. if only one stack is left and the interrupt is not well controlled, the original control sequence will be damaged once a call subroutine is executed in the interrupt subroutine. every interrupt has the capability of waking up the microcontroller when it is in the sleep or idle mode, the wake up being generated when the interrupt request fag changes from low to high. if it is required to prevent a certain interrupt from waking up the microcontroller then its respective request fag should be frst set high before enter sleep or idle mode. as only the program counter is pushed onto the stack, then when the interrupt is serviced, if the contents of the accumulator, status register or other registers are altered by the interrupt service program, their contents should be saved to the memory at the beginning of the interrupt service routine. to return from an interrupt subroutine, either a ret or reti instruction may be executed. the reti instruction in addition to executing a return to the main program also automatically sets the emi bit high to allow further interrupts. the ret instruction however only executes a return to the main program leaving the emi bit in its present zero state and therefore disabling the execution of further interrupts.
rev. 1.20 144 ????st 2?? 201? rev. 1.20 145 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom confguration options confguration options refer to certain options within the mcu that are programmed into the device during the programming process. during the development process, these options are selected using the ht-ide software development tools. as these options are programmed into the device using the hardware programming tools, once they are selected they cannot be changed later using the application program. all options must be defned for proper system function, the details of which are shown in the table. no. options 1 hi?h speed system oscillator selection f h C hxt or hirc 2 low speed system oscillator selection f sub C lxt or lirc 3 hirc freq?ency selection f hirc C ?mhz? 12mhz or 16mhz
rev. 1.20 146 ????st 2?? 201? rev. 1.20 14? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom application circuits vdd vss v dd pc0/osc1 pc1/osc2 osc circ?it pb0/xt1 pb1/xt2 osc circ?it see oscillator section see oscillator section ?n0~?n? scom0~scom5 p?0~p?? pb0~pb6 pc0~pc6 0.1f tx rx sseg0~sseg19
rev. 1.20 146 ????st 2?? 201? rev. 1.20 14? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom instruction set introduction central to the successful operation of any microcontroller is its instruction set, which is a set of program instruction codes that directs the microcontroller to perform certain operations. in the case of holtek microcontroller, a comprehensive and fexible set of over 60 instructions is provided to enable programmers to implement their application with the minimum of programming overheads. for easier understanding of the various instruction codes, they have been subdivided into several functional groupings. instruction timing most instructions are implemented within one instruction cycle. the exceptions to this are branch, call, or table read instructions where two instruction cycles are required. one instruction cycle is equal to 4 system clock cycles, therefore in the case of an 8mhz system oscillator, most instructions would be implemented within 0.5s and branch or call instructions would be implemented within 1s. although instructions which require one more cycle to implement are generally limited to the jmp, call, ret, reti and table read instructions, it is important to realize that any other instructions which involve manipulation of the program counter low register or pcl will also take one more cycle to implement. as instructions which change the contents of the pcl will imply a direct jump to that new address, one more cycle will be required. examples of such instructions would be "clr pcl" or "mov pcl, a". for the case of skip instructions, it must be noted that if the result of the comparison involves a skip operation then this will also take one more cycle, if no skip is involved then only one cycle is required. moving and transferring data the transfer of data within the microcontroller program is one of the most frequently used operations. making use of three kinds of mov instructions, data can be transferred from registers to the accumulator and vice-versa as well as being able to move specifc immediate data directly into the accumulator. one of the most important data transfer applications is to receive data from the input ports and transfer data to the output ports. arithmetic operations the ability to perform certain arithmetic operations and data manipulation is a necessary feature of most microcontroller applications. within the holtek microcontroller instruction set are a range of add and subtract instruction mnemonics to enable the necessary arithmetic to be carried out. care must be taken to ensure correct handling of carry and borrow data when results exceed 255 for addition and less than 0 for subtraction. the increment and decrement instructions inc, inca, dec and deca provide a simple means of increasing or decreasing by a value of one of the values in the destination specifed.
rev. 1.20 14? ????st 2?? 201? rev. 1.20 149 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom logical and rotate operation the standard logical operations such as and, or, xor and cpl all have their own instruction within the holtek microcontroller instruction set. as with the case of most instructions involving data manipulation, data must pass through the accumulator which may involve additional programming steps. in all logical data operations, the zero flag may be set if the result of the operation is zero. another form of logical data manipulation comes from the rotate instructions such as rr, rl, rrc and rlc which provide a simple means of rotating one bit right or left. different rotate instructions exist depending on program requirements. rotate instructions are useful for serial port programming applications where data can be rotated from an internal register into the carry bit from where it can be examined and the necessary serial bit set high or low. another application which rotate data operations are used is to implement multiplication and division calculations. branches and control transfer program branching takes the form of either jumps to specifed locations using the jmp instruction or to a subroutine using the call instruction. they differ in the sense that in the case of a subroutine call, the program must return to the instruction immediately when the subroutine has been carried out. this is done by placing a return instruction "ret" in the subroutine which will cause the program to jump back to the address right after the call instruction. in the case of a jmp instruction, the program simply jumps to the desired location. there is no requirement to jump back to the original jumping off point as in the case of the call instruction. one special and extremely useful set of branch instructions are the conditional branches. here a decision is frst made regarding the condition of a certain data memory or individual bits. depending upon the conditions, the program will continue with the next instruction or skip over it and jump to the following instruction. these instructions are the key to decision making and branching within the program perhaps determined by the condition of certain input switches or by the condition of internal data bits. bit operations the ability to provide single bit operations on data memory is an extremely fexible feature of all holtek microcontrollers. this feature is especially useful for output port bit programming where individual bits or port pins can be directly set high or low using either the "set [m].i" or "clr [m]. i" instructions respectively. the feature removes the need for programmers to frst read the 8-bit output port, manipulate the input data to ensure that other bits are not changed and then output the port with the correct new data. this read-modify-write process is taken care of automatically when these bit operation instructions are used. table read operations data storage is normally implemented by using registers. however, when working with large amounts of fxed data, the volume involved often makes it inconvenient to store the fxed data in the data memory. to overcome this problem, holtek microcontrollers allow an area of program memory to be set as a table where data can be directly stored. a set of easy to use instructions provides the means by which this fixed data can be referenced and retrieved from the program memory. other operations in addition to the above functional instructions, a range of other instructions also exist such as the "halt" instruction for power-down operations and instructions to control the operation of the watchdog timer for reliable program operations under extreme electric or electromagnetic environments. for their relevant operations, refer to the functional related sections.
rev. 1.20 14? ????st 2?? 201? rev. 1.20 149 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom instruction set summary the following table depicts a summary of the instruction set categorised according to function and can be consulted as a basic instruction reference using the following listed conventions. table conventions x: bits immediate data m: data memory address a: accumulator i: 0~7 number of bits addr: program memory address mnemonic description cycles flag affected arithmetic ?dd ??[m] ?dd data memory to ?cc 1 z? c? ?c? ov ?ddm ??[m] ?dd ?cc to data memory 1 note z? c? ?c? ov ?dd ??x ?dd immediate data to ?cc 1 z? c? ?c? ov ?dc ??[m] ?dd data memory to ?cc with carry 1 z? c? ?c? ov ?dcm ??[m] ?dd ?cc to data memory with carry 1 note z? c? ?c? ov sub ??x s?btract immediate data from the ?cc 1 z? c? ?c? ov sub ??[m] s?btract data memory from ?cc 1 z? c? ?c? ov subm ??[m] s?btract data memory from ?cc with res?lt in data memory 1 note z? c? ?c? ov sbc ??[m] s?btract data memory from ?cc with carry 1 z? c? ?c? ov sbcm ??[m] s?btract data memory from ?cc with carry ? res?lt in data memory 1 note z? c? ?c? ov d?? [m] decimal adj?st ?cc for ?ddition with res?lt in data memory 1 note c logic operation ?nd ??[m] lo?ical ?nd data memory to ?cc 1 z or ??[m] lo?ical or data memory to ?cc 1 z xor ??[m] lo?ical xor data memory to ?cc 1 z ?ndm ??[m] lo?ical ?nd ?cc to data memory 1 note z orm ??[m] lo?ical or ?cc to data memory 1 note z xorm ??[m] lo?ical xor ?cc to data memory 1 note z ?nd ??x lo?ical ?nd immediate data to ?cc 1 z or ??x lo?ical or immediate data to ?cc 1 z xor ??x lo?ical xor immediate data to ?cc 1 z cpl [m] complement data memory 1 note z cpl? [m] complement data memory with res?lt in ?cc 1 z increment & decrement inc? [m] increment data memory with res?lt in ?cc 1 z inc [m] increment data memory 1 note z dec? [m] decrement data memory with res?lt in ?cc 1 z dec [m] decrement data memory 1 note z rotate rr? [m] rotate data memory ri?ht with res?lt in ?cc 1 none rr [m] rotate data memory ri?ht 1 note none rrc? [m] rotate data memory ri?ht thro??h carry with res?lt in ?cc 1 c rrc [m] rotate data memory ri?ht thro??h carry 1 note c rl? [m] rotate data memory left with res?lt in ?cc 1 none rl [m] rotate data memory left 1 note none rlc? [m] rotate data memory left thro??h carry with res?lt in ?cc 1 c rlc [m] rotate data memory left thro??h carry 1 note c
rev. 1.20 150 ????st 2?? 201? rev. 1.20 151 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom mnemonic description cycles flag affected data move mov ??[m] move data memory to ?cc 1 none mov [m]?? move ?cc to data memory 1 note none mov ??x move immediate data to ?cc 1 none bit operation clr [m].i clear bit of data memory 1 note none set [m].i set bit of data memory 1 note none branch operation jmp addr j?mp ?nconditionally 2 none sz [m] skip if data memory is zero 1 note none sz? [m] skip if data memory is zero with data movement to ?cc 1 note none sz [m].i skip if bit i of data memory is zero 1 note none snz [m].i skip if bit i of data memory is not zero 1 note none siz [m] skip if increment data memory is zero 1 note none sdz [m] skip if decrement data memory is zero 1 note none siz? [m] skip if increment data memory is zero with res?lt in ?cc 1 note none sdz? [m] skip if decrement data memory is zero with res?lt in ?cc 1 note none c? ll addr s?bro?tine call 2 none ret ret?rn from s?bro?tine 2 none ret ??x ret?rn from s?bro?tine and load immediate data to ?cc 2 none reti ret?rn from interr?pt 2 none table read operation t ?brd [m] read table (specifc page) to tblh and data memory 2 note none t ?brdc [m] read table (c?rrent pa? e) to tblh and data memory 2 note none t ? brdl [m] read table (last pa? e) to tblh and data memory 2 note none miscellaneous nop no operation 1 none clr [m] clear data memory 1 note none set [m] set data memory 1 note none clr wdt clear watchdo ? timer 1 to ? pdf clr wdt1 pre-clear watchdo ? timer 1 to ? pdf clr wdt2 pre-clear watchdo ? timer 1 to ? pdf sw ? p [m] swap nibbles of data memory 1 note none sw ?p ? [m] swap nibbles of data memory with res?lt in ?cc 1 none h? lt enter power down mode 1 to ? pdf note: 1. for skip instructions, if the result of the comparison involves a skip then two cycles are required, if no skip takes place only one cycle is required. 2. any instruction which changes the contents of the pcl will also require 2 cycles for execution. 3. for the "clr wdt1" and "clr wdt2" instructions the to and pdf flags may be affected by the execution status. the to and pdf flags are cleared after both "clr wdt1" and "clr wdt2" instructions are consecutively executed. otherwise the to and pdf fags remain unchanged.
rev. 1.20 150 ????st 2?? 201? rev. 1.20 151 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom instruction defnition adc a,[m] add data memory to acc with carry description the contents of the specifed data memory, accumulator and the carry fag are added. the result is stored in the accumulator. operation acc acc + [m] + c affected fag(s) ov, z, ac, c adcm a,[m] add acc to data memory with carry description the contents of the specifed data memory, accumulator and the carry fag are added. the result is stored in the specifed data memory. operation [m] acc + [m] + c affected fag(s) ov, z, ac, c add a,[m] add data memory to acc description the contents of the specifed data memory and the accumulator are added. the result is stored in the accumulator. operation acc acc + [m] affected fag(s) ov, z, ac, c add a,x add immediate data to acc description the contents of the accumulator and the specifed immediate data are added. the result is stored in the accumulator. operation acc acc + x affected fag(s) ov, z, ac, c addm a,[m] add acc to data memory description the contents of the specifed data memory and the accumulator are added. the result is stored in the specifed data memory. operation [m] acc + [m] affected fag(s) ov, z, ac, c and a,[m] logical and data memory to acc description data in the accumulator and the specifed data memory perform a bitwise logical and operation. the result is stored in the accumulator. operation acc acc and [m] affected fag(s) z and a,x logical and immediate data to acc description data in the accumulator and the specifed immediate data perform a bit wise logical and operation. the result is stored in the accumulator. operation acc acc and x affected fag(s) z andm a,[m] logical and acc to data memory description data in the specifed data memory and the accumulator perform a bitwise logical and operation. the result is stored in the data memory. operation [m] acc and [m] affected fag(s) z
rev. 1.20 152 ????st 2?? 201? rev. 1.20 153 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom call addr subroutine call description unconditionally calls a subroutine at the specifed address. the program counter then increments by 1 to obtain the address of the next instruction which is then pushed onto the stack. the specifed address is then loaded and the program continues execution from this new address. as this instruction requires an additional operation, it is a two cycle instruction. operation stack program counter + 1 program counter addr affected fag(s) none clr [m] clear data memory description each bit of the specifed data memory is cleared to 0. operation [m] 00h affected fag(s) none clr [m].i clear bit of data memory description bit i of the specifed data memory is cleared to 0. operation [m].i 0 affected fag(s) none clr wdt clear watchdog timer description the to, pdf fags and the wdt are all cleared. operation wdt cleared to 0 pdf 0 affected fag(s) to, pdf clr wdt1 pre-clear watchdog timer description the to, pdf fags and the wdt are all cleared. note that this instruction works in conjunction with clr wdt2 and must be executed alternately with clr wdt2 to have effect. repetitively executing this instruction without alternately executing clr wdt2 will have no effect. operation wdt cleared to 0 pdf 0 affected fag(s) to, pdf clr wdt2 pre-clear watchdog timer description the to, pdf fags and the wdt are all cleared. note that this instruction works in conjunction with clr wdt1 and must be executed alternately with clr wdt1 to have effect. repetitively executing this instruction without alternately executing clr wdt1 will have no effect. operation wdt cleared to 0 pdf 0 affected fag(s) to, pdf cpl [m] complement data memory description each bit of the specifed data memory is logically complemented (1s complement). bits which previously contained a 1 are changed to 0 and vice versa. operation [m] [m] affected fag(s) z
rev. 1.20 152 ????st 2?? 201? rev. 1.20 153 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom cpla [m] complement data memory with result in acc description each bit of the specifed data memory is logically complemented (1s complement). bits which previously contained a 1 are changed to 0 and vice versa. the complemented result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc [m] affected fag(s) z daa [m] decimal-adjust acc for addition with result in data memory description convert the contents of the accumulator value to a bcd (binary coded decimal) value resulting from the previous addition of two bcd variables. if the low nibble is greater than 9 or if ac fag is set, then a value of 6 will be added to the low nibble. otherwise the low nibble remains unchanged. if the high nibble is greater than 9 or if the c fag is set, then a value of 6 will be added to the high nibble. essentially, the decimal conversion is performed by adding 00h, 06h, 60h or 66h depending on the accumulator and fag conditions. only the c fag may be affected by this instruction which indicates that if the original bcd sum is greater than 100, it allows multiple precision decimal addition. operation [m] acc + 00h or [m] acc + 06h or [m] acc + 60h or [m] acc + 66h affected fag(s) c dec [m] decrement data memory description data in the specifed data memory is decremented by 1. operation [m] [m] ? 1 affected fag(s) z deca [m] decrement data memory with result in acc description data in the specifed data memory is decremented by 1. the result is stored in the accumulator. the contents of the data memory remain unchanged. operation acc [m] ? 1 affected fag(s) z halt enter power down mode description this instruction stops the program execution and turns off the system clock. the contents of the data memory and registers are retained. the wdt and prescaler are cleared. the power down fag pdf is set and the wdt time-out fag to is cleared. operation to 0 pdf 1 affected fag(s) to, pdf inc [m] increment data memory description data in the specifed data memory is incremented by 1. operation [m] [m] + 1 affected fag(s) z inca [m] increment data memory with result in acc description data in the specifed data memory is incremented by 1. the result is stored in the accumulator. the contents of the data memory remain unchanged. operation acc [m] + 1 affected fag(s) z
rev. 1.20 154 ????st 2?? 201? rev. 1.20 155 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom jmp addr jump unconditionally description the contents of the program counter are replaced with the specifed address. program execution then continues from this new address. as this requires the insertion of a dummy instruction while the new address is loaded, it is a two cycle instruction. operation program counter addr affected fag(s) none mov a,[m] move data memory to acc description the contents of the specifed data memory are copied to the accumulator. operation acc [m] affected fag(s) none mov a,x move immediate data to acc description the immediate data specifed is loaded into the accumulator. operation acc x affected fag(s) none mov [m],a move acc to data memory description the contents of the accumulator are copied to the specifed data memory. operation [m] acc affected fag(s) none nop no operation description no operation is performed. execution continues with the next instruction. operation no operation affected fag(s) none or a,[m] logical or data memory to acc description data in the accumulator and the specifed data memory perform a bitwise logical or operation. the result is stored in the accumulator. operation acc acc or [m] affected fag(s) z or a,x logical or immediate data to acc description data in the accumulator and the specifed immediate data perform a bitwise logical or operation. the result is stored in the accumulator. operation acc acc or x affected fag(s) z orm a,[m] logical or acc to data memory description data in the specifed data memory and the accumulator perform a bitwise logical or operation. the result is stored in the data memory. operation [m] acc or [m] affected fag(s) z ret return from subroutine description the program counter is restored from the stack. program execution continues at the restored address. operation program counter stack affected fag(s) none
rev. 1.20 154 ????st 2?? 201? rev. 1.20 155 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom ret a,x return from subroutine and load immediate data to acc description the program counter is restored from the stack and the accumulator loaded with the specifed immediate data. program execution continues at the restored address. operation program counter stack acc x affected fag(s) none reti return from interrupt description the program counter is restored from the stack and the interrupts are re-enabled by setting the emi bit. emi is the master interrupt global enable bit. if an interrupt was pending when the reti instruction is executed, the pending interrupt routine will be processed before returning to the main program. operation program counter stack emi 1 affected fag(s) none rl [m] rotate data memory left description the contents of the specifed data memory are rotated left by 1 bit with bit 7 rotated into bit 0. operation [m].(i+1) [m].i; (i=0~6) [m].0 [m].7 affected fag(s) none rla [m] rotate data memory left with result in acc description the contents of the specifed data memory are rotated left by 1 bit with bit 7 rotated into bit 0. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.(i+1) [m].i; (i=0~6) acc.0 [m].7 affected fag(s) none rlc [m] rotate data memory left through carry description the contents of the specifed data memory and the carry fag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry fag is rotated into bit 0. operation [m].(i+1) [m].i; (i=0~6) [m].0 c c [m].7 affected fag(s) c rlca [m] rotate data memory left through carry with result in acc description data in the specifed data memory and the carry fag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry fag is rotated into the bit 0. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.(i+1) [m].i; (i=0~6) acc.0 c c [m].7 affected fag(s) c rr [m] rotate data memory right description the contents of the specifed data memory are rotated right by 1 bit with bit 0 rotated into bit 7. operation [m].i [m].(i+1); (i=0~6) [m].7 [m].0 affected fag(s) none
rev. 1.20 156 ????st 2?? 201? rev. 1.20 15? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom rra [m] rotate data memory right with result in acc description data in the specifed data memory is rotated right by 1 bit with bit 0 rotated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i [m].(i+1); (i=0~6) acc.7 [m].0 affected fag(s) none rrc [m] rotate data memory right through carry description the contents of the specifed data memory and the carry fag are rotated right by 1 bit. bit 0 replaces the carry bit and the original carry fag is rotated into bit 7. operation [m].i [m].(i+1); (i=0~6) [m].7 c c [m].0 affected fag(s) c rrca [m] rotate data memory right through carry with result in acc description data in the specifed data memory and the carry fag are rotated right by 1 bit. bit 0 replaces the carry bit and the original carry fag is rotated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i [m].(i+1); (i=0~6) acc.7 c c [m].0 affected fag(s) c sbc a,[m] subtract data memory from acc with carry description the contents of the specifed data memory and the complement of the carry fag are subtracted from the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. operation acc acc ? [m] ? c affected fag(s) ov, z, ac, c sbcm a,[m] subtract data memory from acc with carry and result in data memory description the contents of the specifed data memory and the complement of the carry fag are subtracted from the accumulator. the result is stored in the data memory. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. operation [m] acc ? [m] ? c affected fag(s) ov, z, ac, c sdz [m] skip if decrement data memory is 0 description the contents of the specifed data memory are frst decremented by 1. if the result is 0 the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m] [m] ? 1 skip if [m]=0 affected fag(s) none
rev. 1.20 156 ????st 2?? 201? rev. 1.20 15? ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom sdza [m] skip if decrement data memory is zero with result in acc description the contents of the specifed data memory are frst decremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specifed data memory contents remain unchanged. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. operation acc [m] ? 1 skip if acc=0 affected fag(s) none set [m] set data memory description each bit of the specifed data memory is set to 1. operation [m] ffh affected fag(s) none set [m].i set bit of data memory description bit i of the specifed data memory is set to 1. operation [m].i 1 affected fag(s) none siz [m] skip if increment data memory is 0 description the contents of the specifed data memory are frst incremented by 1. if the result is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m] [m] + 1 skip if [m]=0 affected fag(s) none siza [m] skip if increment data memory is zero with result in acc description the contents of the specifed data memory are frst incremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specifed data memory contents remain unchanged. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc [m] + 1 skip if acc=0 affected fag(s) none snz [m].i skip if bit i of data memory is not 0 description if bit i of the specifed data memory is not 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is 0 the program proceeds with the following instruction. operation skip if [m].i 0 affected fag(s) none sub a,[m] subtract data memory from acc description the specifed data memory is subtracted from the contents of the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. operation acc acc ? [m] affected fag(s) ov, z, ac, c
rev. 1.20 15? ????st 2?? 201? rev. 1.20 159 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom subm a,[m] subtract data memory from acc with result in data memory description the specifed data memory is subtracted from the contents of the accumulator. the result is stored in the data memory. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. operation [m] acc ? [m] affected fag(s) ov, z, ac, c sub a,x subtract immediate data from acc description the immediate data specifed by the code is subtracted from the contents of the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. operation acc acc ? x affected fag(s) ov, z, ac, c swap [m] swap nibbles of data memory description the low-order and high-order nibbles of the specifed data memory are interchanged. operation [m].3~[m].0 ? [m].7~[m].4 affected fag(s) none swapa [m] swap nibbles of data memory with result in acc description the low-order and high-order nibbles of the specifed data memory are interchanged. the result is stored in the accumulator. the contents of the data memory remain unchanged. operation acc.3~acc.0 [m].7~[m].4 acc.7~acc.4 [m].3~[m].0 affected fag(s) none sz [m] skip if data memory is 0 description if the contents of the specifed data memory is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation skip if [m]=0 affected fag(s) none sza [m] skip if data memory is 0 with data movement to acc description the contents of the specifed data memory are copied to the accumulator. if the value is zero, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc [m] skip if [m]=0 affected fag(s) none sz [m].i skip if bit i of data memory is 0 description if bit i of the specifed data memory is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. operation skip if [m].i=0 affected fag(s) none
rev. 1.20 15? ????st 2?? 201? rev. 1.20 159 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom tabrd [m] read table (specifc page) to tblh and data memory description the low byte of the program code (specifc page) addressed by the table pointer pair (tbhp and tblp) is moved to the specifed data memory and the high byte moved to tblh. operation [m] program code (low byte) tblh program code (high byte) affected fag(s) none tabrdc [m] read table (current page) to tblh and data memory description the low byte of the program code (current page) addressed by the table pointer (tblp) is moved to the specifed data memory and the high byte moved to tblh. operation [m] program code (low byte) tblh program code (high byte) affected fag(s) none tabrdl [m] read table (last page) to tblh and data memory description the low byte of the program code (last page) addressed by the table pointer (tblp) is moved to the specifed data memory and the high byte moved to tblh. operation [m] program code (low byte) tblh program code (high byte) affected fag(s) none xor a,[m] logical xor data memory to acc description data in the accumulator and the specifed data memory perform a bitwise logical xor operation. the result is stored in the accumulator. operation acc acc xor [m] affected fag(s) z xorm a,[m] logical xor acc to data memory description data in the specifed data memory and the accumulator perform a bitwise logical xor operation. the result is stored in the data memory. operation [m] acc xor [m] affected fag(s) z xor a,x logical xor immediate data to acc description data in the accumulator and the specifed immediate data perform a bitwise logical xor operation. the result is stored in the accumulator. operation acc acc xor x affected fag(s) z
rev. 1.20 160 ????st 2?? 201? rev. 1.20 161 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom package information note that the package information provided here is for consultation purposes only. as this information may be updated at regular intervals users are reminded to consult the holtek website for the latest version of the package/carton information . additional supplementary information with regard to packaging is listed below. click on the relevant section to be transferred to the relevant website page. ? package information (include outline dimensions, product tape and reel specifcations) ? the operation instruction of packing materials ? carton information
rev. 1.20 160 ????st 2?? 201? rev. 1.20 161 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom 16-pin nsop (150mil) outline dimensions               symbol dimensions in inch min. nom. max. ? 0.236 bsc b 0.154 bsc c 0.012 0.020 c 0.390 bsc d 0.069 e 0.050 bsc f 0.004 0.010 g 0.016 0.050 h 0.004 0.010 0 ? symbol dimensions in mm min. nom. max. ? 6 bsc b 3.9 bsc c 0.31 0.51 c 9.9 bsc d 1.?5 e 1.2? bsc f 0.10 0.25 g 0.40 1.2? h 0.10 0.25 0 ?
rev. 1.20 162 ????st 2?? 201? rev. 1.20 163 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom 20-pin nsop (150mil) outline dimensions              symbol dimensions in inch min. nom. max. ? 0.22? 0.236 0.244 b 0.146 0.154 0.161 c 0.009 0.012 c 0.3?2 0.390 0.39? d 0.069 e 0.032 bsc f 0.002 0.009 g 0.020 0.031 h 0.00? 0.010 0 ? symbol dimensions in mm min. nom. max. ? 5.?0 6.00 6.20 b 3.?0 3.90 4.10 c 0.23 0.30 c 9.?0 9.90 10.10 d 1.?5 e 0.?0 bsc f 0.05 0.23 g 0.50 0.?0 h 0.21 0.25 0 ?
rev. 1.20 162 ????st 2?? 201? rev. 1.20 163 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom 24-pin sop (300mil) outline dimensions              symbol dimensions in inch min. nom. max. ? 0.406 bsc b 0.295 bsc c 0.012 0.020 c 0.606 bsc d 0.104 e 0.050 bsc f 0.00 4 0.012 g 0.016 0.050 h 0.00? 0.01 3 0 ? symbol dimensions in mm min. nom. max. ? 10.30 bsc b ?.5 bsc c 0.31 0.51 c 15.4 bsc d 2.65 e 1.2? bsc f 0.10 0.30 g 0.40 1.2? h 0.20 0.33 0 ?
rev. 1.20 164 ????st 2?? 201? rev. 1.20 165 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom 24 -pin ssop ( 150 mil) outline dimensions              symbol dimensions in inch min. nom. max. ? 0.236 bsc b 0.154 bsc c 0.00? 0.012 c 0.341 bsc d 0.069 e 0.025 bsc f 0.004 0.010 g 0.016 0.050 h 0.004 0.010 0 ? symbol dimensions in mm min. nom. max. ? 6.000 bsc b 3.900 bsc c 0.20 0.30 c ?.660 bsc d 1.?5 e 0.635 bsc f 0.10 0.25 g 0.41 1.2? h 0.10 0.25 0 ?
rev. 1.20 164 ????st 2?? 201? rev. 1.20 165 ????st 2?? 201? HT66F0176 a/d flash mcu with eeprom HT66F0176 a/d flash mcu with eeprom copyri?ht ? 201? by holtek semiconductor inc. the information appearin ? in this data sheet is believed to be acc? rate at the time of p ? blication. however ? holtek ass? mes no responsibility arisin? from the ? se of the specifcations described. the applications mentioned herein are used solely for the p?rpose of ill?stration and holtek makes no warranty or representation that s? ch applications will be s? itable witho? t f? rther modification? nor recommends the ?se of its prod?cts for application that may present a risk to h?man life d?e to malf ? nction or otherwise. holtek's prod? cts are not a? thorized for ? se as critical components in life s?pport devices or systems. holtek reserves the ri?ht to alter its products without prior notifcation. for the most up-to-date information, please visit o? r web site at http://www.holtek.com.tw.


▲Up To Search▲   

 
Price & Availability of HT66F0176

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X